diff --git a/common/dialogs/panel_setup_severities.cpp b/common/dialogs/panel_setup_severities.cpp index 5d256a7c5d..7db267b7d4 100644 --- a/common/dialogs/panel_setup_severities.cpp +++ b/common/dialogs/panel_setup_severities.cpp @@ -54,6 +54,9 @@ PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, int errorCode = item.GetErrorCode(); wxString msg = item.GetErrorText(); + if( m_pinMapSpecialCase && errorCode == m_pinMapSpecialCase->GetErrorCode() ) + continue; + // When msg is empty, for some reason, the current errorCode is not supported // by the RC_ITEM aDummyItem. // Skip this errorCode. diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 1344159980..1f3653e78c 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -393,6 +393,8 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco PROF_COUNTER update_items( "updateItemConnectivity" ); + m_sheetList = aSheetList; + for( const SCH_SHEET_PATH& sheet : aSheetList ) { std::vector items; @@ -2075,6 +2077,10 @@ int CONNECTION_GRAPH::RunERC() error_count++; } + // Hierarchical sheet checking is done at the schematic level + if( settings.IsTestEnabled( ERCE_HIERACHICAL_LABEL ) ) + error_count += ercCheckHierSheets(); + return error_count; } @@ -2561,3 +2567,50 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ) return true; } + + +int CONNECTION_GRAPH::ercCheckHierSheets() +{ + int errors = 0; + + for( const SCH_SHEET_PATH& sheet : m_sheetList ) + { + for( SCH_ITEM* item : sheet.LastScreen()->Items() ) + { + if( item->Type() != SCH_SHEET_T ) + continue; + + SCH_SHEET* parentSheet = static_cast( item ); + + std::map pins; + + for( SCH_SHEET_PIN* pin : parentSheet->GetPins() ) + pins[pin->GetText()] = pin; + + for( SCH_ITEM* subItem : parentSheet->GetScreen()->Items() ) + { + if( subItem->Type() == SCH_HIER_LABEL_T ) + { + SCH_HIERLABEL* label = static_cast( subItem ); + pins.erase( label->GetText() ); + } + } + + for( const std::pair& unmatched : pins ) + { + std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_HIERACHICAL_LABEL ); + ercItem->SetItems( unmatched.second ); + ercItem->SetErrorMessage( wxString::Format( + _( "Sheet port %s has no matching hierarchical label inside the sheet" ), + unmatched.first ) ); + + SCH_MARKER* marker = new SCH_MARKER( ercItem, unmatched.second->GetPosition() ); + sheet.LastScreen()->Append( marker ); + + errors++; + } + } + } + + return errors; +} diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index 30ce9aaf8f..460d9e3c6f 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -301,7 +301,10 @@ public: static bool m_allowRealTime; private: + // All the sheets in the schematic (as long as we don't have partial updates) + SCH_SHEET_LIST m_sheetList; + // All connectable items in the schematic std::vector m_items; // The owner of all CONNECTION_SUBGRAPH objects @@ -502,6 +505,15 @@ private: */ bool ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ); + /** + * Checks that a hierarchical sheet has at least one matching label inside the sheet for each + * port on the parent sheet object + * + * @param aSubgraph is the subgraph to examine + * @return the number of errors found + */ + int ercCheckHierSheets(); + }; #endif