Show ERC errors when any label only has 1 pin

To be connected, the label must have at least two pins on a subgraph
(or, in the case of a hierarchical label, two pins somewhere in its
connection)

Fixes https://gitlab.com/kicad/code/kicad/issues/7203
This commit is contained in:
Seth Hillbrand 2022-09-09 17:19:29 -07:00
parent 16479277cc
commit 05cdf915d0
1 changed files with 8 additions and 8 deletions

View File

@ -3022,7 +3022,6 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
case SCH_PIN_T:
case SCH_SHEET_PIN_T:
hasOtherConnections = true;
pinCount++;
break;
@ -3041,13 +3040,14 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
wxString name = EscapeString( text->GetShownText(), CTX_NETNAME );
// Labels that have multiple pins connected are not dangling (may be used for naming segments)
// so leave them without errors here
if( pinCount > 1 )
return true;
if( isGlobal )
{
// This will be set to true if the global is connected to a pin above, but we want to
// reset this to false so that globals get flagged if they only have a single instance
// connected to a single pin
hasOtherConnections = ( pinCount > 1 );
// Global labels are connected if there is another instance of their name in the circuit
auto it = m_net_name_to_subgraphs_map.find( name );
if( it != m_net_name_to_subgraphs_map.end() )
@ -3058,7 +3058,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
}
else if( text->Type() == SCH_HIER_LABEL_T )
{
// For a hier label, check if the parent pin is connected
// Hierarchical labels are connected if their parents are connected
if( aSubgraph->m_hier_parent
&& ( aSubgraph->m_hier_parent->m_strong_driver
|| aSubgraph->m_hier_parent->m_drivers.size() > 1) )
@ -3080,7 +3080,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
if( neighbor == aSubgraph )
continue;
if( hasPins( neighbor ) )
if( hasPins( neighbor ) && ++pinCount > 1 )
{
hasOtherConnections = true;
break;