diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp index 7e6654f3dd..abb0eedb5f 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp @@ -68,6 +68,8 @@ #include "cbvh_pbrt.h" #include "../../../3d_fastmath.h" +#include + #include #include #include @@ -560,6 +562,7 @@ BVHBuildNode *CBVH_PBRT::recursiveBuild ( std::vector &primiti // Intentionally fall through to SPLITMETHOD::EQUAL_COUNTS since prims // with large overlapping bounding boxes may fail to partition + KI_FALLTHROUGH; case SPLITMETHOD::EQUALCOUNTS: { diff --git a/common/base_units.cpp b/common/base_units.cpp index a83e56fd4e..4555702cf1 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -147,10 +147,12 @@ wxString MessageTextFromValue( EDA_UNITS aUnits, double aValue, bool aUseMils, E case EDA_DATA_TYPE::VOLUME: value = To_User_Unit( aUnits, value, aUseMils ); // Fall through to continue computation + KI_FALLTHROUGH; case EDA_DATA_TYPE::AREA: value = To_User_Unit( aUnits, value, aUseMils ); // Fall through to continue computation + KI_FALLTHROUGH; case EDA_DATA_TYPE::DISTANCE: value = To_User_Unit( aUnits, value, aUseMils ); diff --git a/common/common.cpp b/common/common.cpp index 875bc1a6c5..2f24e692d8 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -548,7 +549,7 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject ) break; } - // else fall through + KI_FALLTHROUGH; default: strResult += str_n; diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index ba115a40f7..90c512de54 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -386,6 +387,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) default: wxASSERT( false ); + KI_FALLTHROUGH; // warn about unhandled GAL canvas type, but continue with the fallback option case GAL_TYPE_NONE: diff --git a/common/page_layout/page_layout_reader.cpp b/common/page_layout/page_layout_reader.cpp index 7c67e84b68..d7b065507e 100644 --- a/common/page_layout/page_layout_reader.cpp +++ b/common/page_layout/page_layout_reader.cpp @@ -177,6 +177,7 @@ wxString convertLegacyVariableRefs( const wxString& aTextbase ) case '8': msg += wxT( "${COMMENT8}" ); break; case '9': msg += wxT( "${COMMENT9}" ); break; } + break; default: break; diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 8d5a0c7b1b..c430153f85 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -819,7 +819,8 @@ void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize, case 900: case 2700: // rotation of 90 degrees or 270 swaps sizes std::swap( size.x, size.y ); - // Intentionally fall through + KI_FALLTHROUGH; + case 0: case 1800: if( trace_mode == SKETCH ) diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index 06b1c5e30c..6187d32c40 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -324,8 +324,8 @@ void PSLIKE_PLOTTER::fputsPostscriptString(FILE *fout, const wxString& txt) case ')': case '\\': putc( '\\', fout ); + KI_FALLTHROUGH; - // FALLTHRU default: putc( ch, fout ); break; diff --git a/common/widgets/lib_tree.cpp b/common/widgets/lib_tree.cpp index 1d4c7b67d3..b3fc9636b2 100644 --- a/common/widgets/lib_tree.cpp +++ b/common/widgets/lib_tree.cpp @@ -23,6 +23,7 @@ */ #include "lib_tree.h" +#include #include #include #include @@ -365,6 +366,7 @@ void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke ) break; } // Intentionally fall through, so the selected component will be treated as the selected one + KI_FALLTHROUGH; default: aKeyStroke.Skip(); // Any other key: pass on to search box directly. diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 0433173de0..96d170a3ce 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -207,7 +208,10 @@ std::vector CONNECTION_SUBGRAPH::GetBusLabels() const // Only consider bus vectors if( label_conn->Type() == CONNECTION_TYPE::BUS ) labels.push_back( item ); + + break; } + default: break; } } diff --git a/eeschema/netlist_object_list.cpp b/eeschema/netlist_object_list.cpp index b4aa88c0f3..e375c944b3 100644 --- a/eeschema/netlist_object_list.cpp +++ b/eeschema/netlist_object_list.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -115,6 +116,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets ) break; // Intentionally fall through if there is no net assigned + KI_FALLTHROUGH; case NETLIST_ITEM::SEGMENT: // Test connections point to point type without bus. @@ -165,6 +167,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets ) break; // Intentionally fall through if there is no bus assigned + KI_FALLTHROUGH; case NETLIST_ITEM::BUS: // Control type connections point to point mode bus diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 87830e6c02..c86db924ca 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -229,6 +230,7 @@ static COMPONENT_ORIENTATION_T kiCadComponentRotation( float eagleDegrees ) { default: wxASSERT_MSG( false, wxString::Format( "Unhandled orientation (%d degrees)", roti ) ); + KI_FALLTHROUGH; case 0: return CMP_ORIENT_0; @@ -1701,8 +1703,8 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( { default: wxASSERT_MSG( false, wxString::Format( "Unhandled orientation (%d degrees)", roti ) ); + KI_FALLTHROUGH; - // fall through case 0: pin->SetOrientation( 'R' ); break; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index df46271f55..2dcfec9aab 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -836,6 +836,8 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) if( item->HitTest( aPosition, aAccuracy ) ) return (SCH_TEXT*) item; + break; + default: ; } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index f8b05b5127..e744cfe70b 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include // for KiROUND #include #include @@ -357,7 +358,7 @@ bool SCH_TEXT::UpdateDanglingState( std::vector& aItemList, case BUS_START_END: m_connectionType = CONNECTION_TYPE::BUS; - // fall through + KI_FALLTHROUGH; case WIRE_START_END: { diff --git a/gerbview/am_param.cpp b/gerbview/am_param.cpp index ba4d44075c..a07ab9984b 100644 --- a/gerbview/am_param.cpp +++ b/gerbview/am_param.cpp @@ -29,6 +29,7 @@ #include #include +#include extern int ReadInt( char*& text, bool aSkipSeparator = true ); extern double ReadDouble( char*& text, bool aSkipSeparator = true ); @@ -184,7 +185,9 @@ bool AM_PARAM::ReadParam( char*& aText ) if( !found ) // happens when a string starts by ',' before any param break; // just skip this separator - // fall through + + KI_FALLTHROUGH; + case '\n': case '\r': case 0: // EOL diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index 5c57a83221..7f723f723c 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -234,7 +234,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, msg.Printf( _("GERBER file \"%s\" may not display as intended." ), m_FileName.ToAscii() ); AddMessageToList( msg ); - // Fallthrough + KI_FALLTHROUGH; case 'L': // No Leading 0 m_NoTrailingZeros = false; diff --git a/include/macros.h b/include/macros.h index 7d51b4d46a..ddb5611b2b 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,8 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * + * Copyright (C) 2020 Ian McInerney * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2015 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,6 +38,57 @@ #include #include // std::shared_ptr +#if defined( __has_attribute ) + #define KI_HAS_ATTRIBUTE( x ) __has_attribute( x ) +#else + #define KI_HAS_ATTRIBUTE( x ) 0 +#endif + +// Based on the declaration inside the LLVM source code +#if defined( __cplusplus ) && defined( __has_cpp_attribute ) + #define KI_HAS_CPP_ATTRIBUTE( x ) __has_cpp_attribute( x ) +#else + #define KI_HAS_CPP_ATTRIBUTE( x ) 0 +#endif + +/** + * The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely + * fallthrough from one to the next. It must be followed by a ";". + * + * Sample code: + * switch( a ) + * { + * case 1: + * // Some code + * KI_FALLTHROUGH; + * + * case 2: + * // More code + * break; + * } + */ +#if __cplusplus >= 201703L + // C++ 17 includes this macro on all compilers + #define KI_FALLTHROUGH [[fallthrough]] + +#elif KI_HAS_CPP_ATTRIBUTE( clang::fallthrough ) + // Clang provides this attribute to silence the "-Wimplicit-fallthrough" warning + #define KI_FALLTHROUGH [[clang::fallthrough]] + +#elif KI_HAS_CPP_ATTRIBUTE( gnu::fallthrough ) + // GNU-specific C++ attribute to sliencing the warning + #define KI_FALLTHROUGH [[gnu::fallthrough]] + +#elif defined( __GNUC__ ) && __GNUC__ >= 7 + // GCC 7+ includes the "-Wimplicit-fallthrough" warning, and this attribute to silence it + #define KI_FALLTHROUGH __attribute__ ((fallthrough)) + +#else + // In every other case, don't do anything + #define KI_FALLTHROUGH ( ( void ) 0 ) + +#endif + /** * Macro TO_UTF8 * converts a wxString to a UTF8 encoded C string for all wxWidgets build modes. diff --git a/pagelayout_editor/dialogs/dialog_new_dataitem.cpp b/pagelayout_editor/dialogs/dialog_new_dataitem.cpp index 4a122d8f56..61384c7cbd 100644 --- a/pagelayout_editor/dialogs/dialog_new_dataitem.cpp +++ b/pagelayout_editor/dialogs/dialog_new_dataitem.cpp @@ -125,7 +125,8 @@ void DIALOG_NEW_DATAITEM::initDlg() case WS_DATA_ITEM::WS_BITMAP: case WS_DATA_ITEM::WS_POLYPOLYGON: m_textCtrlText->Enable( false ); - // fall through + KI_FALLTHROUGH; + case WS_DATA_ITEM::WS_TEXT: m_textCtrlEndX->Enable( false ); m_textCtrlEndY->Enable( false ); diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 58cb9aeb67..1d7025b535 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -172,7 +172,8 @@ void EDGE_MODULE::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { case S_ARC: SetAngle( -GetAngle() ); - //Fall through + KI_FALLTHROUGH; + default: case S_SEGMENT: case S_CURVE: @@ -236,7 +237,8 @@ void EDGE_MODULE::Mirror( wxPoint aCentre, bool aMirrorAroundXAxis ) { case S_ARC: SetAngle( -GetAngle() ); - //Fall through + KI_FALLTHROUGH; + default: case S_CURVE: case S_SEGMENT: diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index a91efa92dc..99edbc4a0b 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -298,8 +298,7 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode ) case PCB_MODULE_TEXT_T: // Only user text can be added this way. assert( static_cast( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS ); - - // no break + KI_FALLTHROUGH; case PCB_MODULE_EDGE_T: if( aMode == ADD_MODE::APPEND ) @@ -347,8 +346,7 @@ void MODULE::Remove( BOARD_ITEM* aBoardItem ) wxCHECK_RET( static_cast( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS, "Please report this bug: Invalid remove operation on required text" ); - - // no break + KI_FALLTHROUGH; case PCB_MODULE_EDGE_T: for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it ) @@ -828,7 +826,8 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR inspector, void* testData, const KICAD_T if( result == SEARCH_RESULT::QUIT ) break; - // Intentionally fall through since m_Drawings can hold TYPETEXTMODULE also + // Intentionally fall through since m_Drawings can hold TYPETEXTMODULE also + KI_FALLTHROUGH; case PCB_MODULE_EDGE_T: result = IterateForward( m_drawings, inspector, testData, p ); @@ -949,7 +948,8 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const default: wxASSERT_MSG( false, "Illegal layer" ); // do you really have modules placed on other layers? - // pass through + KI_FALLTHROUGH; + case F_Cu: aLayers[1] = LAYER_MOD_FR; break; diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 448d4e156c..3c0286e652 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include // for KiROUND @@ -277,7 +278,10 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) case PCB_MODULE_ZONE_AREA_T: module = static_cast( item->GetParent() ); - // Fall through + + // Fallthrough to get the zone as well + KI_FALLTHROUGH; + case PCB_ZONE_AREA_T: zone = static_cast( item ); break; diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 6c5e39e893..89d8491381 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -381,6 +381,8 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) if( importFormat >= 0 ) importFile( path, importFormat ); + + break; } // many many others. diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index dfe6141a0c..536cc591e4 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -325,7 +325,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate() // Check angle of arc. if( m_angle.GetValue() == 0 ) error_msgs.Add( _( "The arc angle cannot be zero." ) ); - // Fall through. + KI_FALLTHROUGH; case S_CIRCLE: // Check radius. diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 8159ac7e7d..f866f9e066 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1110,7 +1111,8 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK() if( padlayers_mask[B_Paste] || padlayers_mask[F_Paste] ) error_msgs.Add( _( "Error: Connector pads are not on the solder paste layer\n" "Use SMD pads instead" ) ); - // Intentionally fall through + KI_FALLTHROUGH; + case PAD_ATTRIB_SMD: // SMD and Connector pads (One external copper layer only) { LSET innerlayers_mask = padlayers_mask & LSET::InternalCuMask(); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 8bbe7932ff..5d832648a9 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -41,6 +41,7 @@ #include #include #include // for KiROUND +#include DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : @@ -402,6 +403,8 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) { case PLOT_FORMAT::SVG: m_PlotOptionsSizer->Show( m_svgOptionsSizer ); + KI_FALLTHROUGH; + case PLOT_FORMAT::PDF: m_drillShapeOpt->Enable( true ); m_plotModeOpt->Enable( false ); diff --git a/pcbnew/dialogs/dialog_push_pad_properties.cpp b/pcbnew/dialogs/dialog_push_pad_properties.cpp index 58273cc8fc..284a299c26 100644 --- a/pcbnew/dialogs/dialog_push_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_push_pad_properties.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -72,8 +73,7 @@ void DIALOG_PUSH_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) { case wxID_APPLY: returncode = 1; - - // Fall through + KI_FALLTHROUGH; case wxID_OK: m_Pad_Shape_Filter = m_Pad_Shape_Filter_CB->GetValue(); diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 80a7503489..095c0fd4f2 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -31,6 +31,7 @@ #include #include #include +#include DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const PCBNEW_SELECTION& aItems, @@ -492,7 +493,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow() { default: wxFAIL_MSG("Unhandled via type"); - // fall through + KI_FALLTHROUGH; case VIATYPE::THROUGH: case VIATYPE::BLIND_BURIED: diff --git a/pcbnew/drc/drc_clearance_test_functions.cpp b/pcbnew/drc/drc_clearance_test_functions.cpp index 01129061e9..5541913011 100644 --- a/pcbnew/drc/drc_clearance_test_functions.cpp +++ b/pcbnew/drc/drc_clearance_test_functions.cpp @@ -39,6 +39,7 @@ #include #include #include // for KiROUND +#include /** @@ -1288,7 +1289,8 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi padHalfsize.y -= r; distToLine += r; } - // Fall through + KI_FALLTHROUGH; + case PAD_SHAPE_RECT: // the area to test is a rounded rectangle. // this can be done by testing 2 rectangles and 4 circles (the corners) diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 2d6a6c5eb1..d40733c45f 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -479,7 +479,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) { default: wxASSERT_MSG( false, "Pad type not implemented" ); - // fall-through + KI_FALLTHROUGH; case PAD_SHAPE_CIRCLE: fprintf( aFile, " ROUND %g\n", diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index c9f3484370..be38b8356c 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1192,6 +1192,7 @@ static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aTinLayer, D_P pad_dy = 0; // Intentionally fall through and treat a rectangle as a trapezoid with no sloped sides + KI_FALLTHROUGH; case PAD_SHAPE_TRAPEZOID: { diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index ccebaf66a6..bfe5509604 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -110,7 +110,8 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ default: wxASSERT( false ); - // fall through + KI_FALLTHROUGH; + case PLOT_FORMAT::PDF: case PLOT_FORMAT::POST: case PLOT_FORMAT::SVG: diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index da82ca42b0..61a41fe705 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -321,7 +321,8 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id ) case ID_SAVE_BOARD: if( !GetBoard()->GetFileName().IsEmpty() ) return SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) ); - // Fall through + + KI_FALLTHROUGH; case ID_COPY_BOARD_AS: case ID_SAVE_BOARD_AS: diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index b5b97e7de2..ed720d5cfe 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -752,8 +752,7 @@ void GPCB_FPL_CACHE::parseParameters( wxArrayString& aParameterList, LINE_READER case '\r': // Element descriptions can span multiple lines. line = aLineReader->ReadLine(); - - // Intentionally fall through + KI_FALLTHROUGH; case '\t': case ' ': diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index db638fb899..859cab120a 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -238,11 +238,11 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) case ID_ALWAYS_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE: m_alwaysShowActiveCopperLayer = true; - // Fallthrough + KI_FALLTHROUGH; case ID_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE: forceActiveLayer = true; - // Fallthrough + KI_FALLTHROUGH; case ID_HIDE_ALL_COPPER_LAYERS: layersToHide = LSET::AllCuMask(); diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 551a7272f3..62dcd907e6 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -438,7 +438,8 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, pad->SetSize( padPlotsSize ); pad->SetRoundRectCornerRadius( margin.x ); } - // Fall through + KI_FALLTHROUGH; + case PAD_SHAPE_TRAPEZOID: case PAD_SHAPE_ROUNDRECT: case PAD_SHAPE_CHAMFERED_RECT: diff --git a/pcbnew/specctra_import_export/specctra.cpp b/pcbnew/specctra_import_export/specctra.cpp index 7e4eb5bfc8..b890961a72 100644 --- a/pcbnew/specctra_import_export/specctra.cpp +++ b/pcbnew/specctra_import_export/specctra.cpp @@ -842,7 +842,8 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) case T_polyline_path: tok = T_path; - // Fall through + KI_FALLTHROUGH; + case T_path: case T_polygon: if( growth->shape ) @@ -937,7 +938,8 @@ void SPECCTRA_DB::doWINDOW( WINDOW* growth ) case T_polyline_path: tok = T_path; - // Fall through + KI_FALLTHROUGH; + case T_path: case T_polygon: if( growth->shape ) @@ -2055,7 +2057,8 @@ void SPECCTRA_DB::doSHAPE( SHAPE* growth ) { case T_polyline_path: tok = T_path; - // Fall through + KI_FALLTHROUGH; + case T_rect: case T_circle: case T_path: @@ -2799,7 +2802,8 @@ void SPECCTRA_DB::doWIRE( WIRE* growth ) case T_polyline_path: tok = T_path; - // Fall through + KI_FALLTHROUGH; + case T_path: case T_polygon: if( growth->shape ) diff --git a/pcbnew/tools/grid_helper.cpp b/pcbnew/tools/grid_helper.cpp index 147314eda9..ec8bd390e9 100644 --- a/pcbnew/tools/grid_helper.cpp +++ b/pcbnew/tools/grid_helper.cpp @@ -38,6 +38,7 @@ using namespace std::placeholders; #include #include +#include #include // for KiROUND #include #include @@ -484,7 +485,8 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, bo case S_CURVE: addAnchor( start, CORNER | SNAPPABLE, dseg ); addAnchor( end, CORNER | SNAPPABLE, dseg ); - //Fallthrough + KI_FALLTHROUGH; + default: origin = dseg->GetStart(); addAnchor( origin, ORIGIN | SNAPPABLE, dseg ); diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index 6c9be7ae36..6f87cae447 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -442,7 +442,8 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool { case PCB_MODULE_T: deep_reBuild_ratsnest = true; // Pointers on pads can be invalid - // Fall through + KI_FALLTHROUGH; + case PCB_ZONE_AREA_T: case PCB_TRACE_T: case PCB_ARC_T: @@ -568,7 +569,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool if( not_found ) wxMessageBox( _( "Incomplete undo/redo operation: some items not found" ) ); - + // Rebuild pointers and connectivity that can be changed. // connectivity can be rebuilt only in the board editor frame if( IsType( FRAME_PCB_EDITOR ) && ( reBuild_ratsnest || deep_reBuild_ratsnest ) )