[packagechooser] Fix fallthrough situation

- Add a FALLTHRU macro to annotate fallthrough situations in both
   Clang and GCC,
 - Annotate intentional fallthroughs.
 - Add missing break which meant that the selection mode was
   always multiple-selection.
This commit is contained in:
Adriaan de Groot 2019-08-06 00:24:53 +02:00
parent 56db9e9341
commit fee2297e67
2 changed files with 5 additions and 2 deletions

View File

@ -198,7 +198,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
) )
string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" ) string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" )
endforeach() endforeach()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='//'" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='//' -DFALLTHRU='[[clang::fallthrough]]'")
# Third-party code where we don't care so much about compiler warnings # Third-party code where we don't care so much about compiler warnings
# (because it's uncomfortable to patch) get different flags; use # (because it's uncomfortable to patch) get different flags; use
@ -225,7 +225,7 @@ else()
set( SUPPRESS_3RDPARTY_WARNINGS "" ) set( SUPPRESS_3RDPARTY_WARNINGS "" )
set( SUPPRESS_BOOST_WARNINGS "" ) set( SUPPRESS_BOOST_WARNINGS "" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='__builtin_unreachable();'" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='__builtin_unreachable();' -DFALLTHRU='/* */'" )
endif() endif()
# Use mark_thirdparty_code() to reduce warnings from the compiler # Use mark_thirdparty_code() to reduce warnings from the compiler

View File

@ -41,9 +41,12 @@ PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent
switch ( mode ) switch ( mode )
{ {
case PackageChooserMode::Optional: case PackageChooserMode::Optional:
FALLTHRU;
case PackageChooserMode::Required: case PackageChooserMode::Required:
ui->products->setSelectionMode( QAbstractItemView::SingleSelection ); ui->products->setSelectionMode( QAbstractItemView::SingleSelection );
break;
case PackageChooserMode::OptionalMultiple: case PackageChooserMode::OptionalMultiple:
FALLTHRU;
case PackageChooserMode::RequiredMultiple: case PackageChooserMode::RequiredMultiple:
ui->products->setSelectionMode( QAbstractItemView::ExtendedSelection ); ui->products->setSelectionMode( QAbstractItemView::ExtendedSelection );
} }