diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 2eba6814b6..1b4b2625c5 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -326,6 +326,9 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter ) if( settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) ) tester.TestTextVars( m_parent->GetCanvas()->GetView()->GetWorksheet() ); + if( settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) ) + tester.TestNoConnectPins(); + // Display diags: m_markerTreeModel->SetProvider( m_markerProvider ); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 34e6cd7cb0..d4af991690 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -525,6 +525,46 @@ void ERC_TESTER::TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemR } } + +int ERC_TESTER::TestNoConnectPins() +{ + int err_count = 0; + + for( const SCH_SHEET_PATH& sheet : m_schematic->GetSheets() ) + { + std::map> pinMap; + + for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) ) + { + SCH_COMPONENT* comp = static_cast( item ); + + for( SCH_PIN* pin : comp->GetSchPins( &sheet ) ) + pinMap[pin->GetPosition()].emplace_back( pin ); + } + + for( auto& pair : pinMap ) + { + if( pair.second.size() > 1 ) + { + err_count++; + + ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED ); + + ercItem->SetItems( pair.second[0], pair.second[1], + pair.second.size() > 2 ? pair.second[2] : nullptr, + pair.second.size() > 3 ? pair.second[3] : nullptr ); + ercItem->SetErrorMessage( _( "Pins with \"no connection\" type are connected" ) ); + + SCH_MARKER* marker = new SCH_MARKER( ercItem, pair.first ); + sheet.LastScreen()->Append( marker ); + } + } + } + + return err_count; +} + + // this code try to detect similar labels, i.e. labels which are identical // when they are compared using case insensitive coparisons. diff --git a/eeschema/erc.h b/eeschema/erc.h index 6a7d2055fc..6bb6d8c4cd 100644 --- a/eeschema/erc.h +++ b/eeschema/erc.h @@ -99,6 +99,13 @@ public: */ int TestMultiunitFootprints(); + /** + * In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type. + * In KiCad 6, this no longer results in those pins joining the net, so we need to warn about it + * @return the error count + */ + int TestNoConnectPins(); + private: /** * Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index c85ddb6997..8614aa19fd 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -141,4 +141,8 @@ bool SCH_PIN::HitTest( const wxPoint& aPosition, int aAccuracy ) const } - +bool SCH_PIN::ConnectionPropagatesTo( const EDA_ITEM* aItem ) const +{ + // Reciprocal checking is done in CONNECTION_GRAPH anyway + return !( m_libPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ); +} diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index b1a6ad04c3..3298145e0b 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -107,6 +107,8 @@ public: bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); } + bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override; + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override {}