From d7f5917fb0cdfa50481ef29d3e96b909528d5ad2 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 27 Nov 2021 22:34:11 -0500 Subject: [PATCH] ERC: flag duplicated local labels with no pins as floating See https://gitlab.com/kicad/code/kicad/-/issues/9593 --- eeschema/connection_graph.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 36e84ed586..482c333b72 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -2769,6 +2769,24 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ) bool hasOtherConnections = false; int pinCount = 0; + auto hasPins = + []( const CONNECTION_SUBGRAPH* aSubgraph ) + { + for( const SCH_ITEM* item : aSubgraph->m_items ) + { + switch( item->Type() ) + { + case SCH_PIN_T: + case SCH_SHEET_PIN_T: + return true; + + default: break; + } + } + + return false; + }; + for( auto item : aSubgraph->m_items ) { switch( item->Type() ) @@ -2850,7 +2868,19 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ) auto it = m_local_label_cache.find( pair ); if( it != m_local_label_cache.end() && it->second.size() > 1 ) - hasOtherConnections = true; + { + for( const CONNECTION_SUBGRAPH* neighbor : it->second ) + { + if( neighbor == aSubgraph ) + continue; + + if( hasPins( neighbor ) ) + { + hasOtherConnections = true; + break; + } + } + } } if( !hasOtherConnections && settings.IsTestEnabled( errCode ) )