Skip to content

Commit 3fc8e8d

Browse files
authoredAug 6, 2018
Merge pull request #7530 from m-kuhn/implicit-fallthrough
Enable -Wimplicit-fallthrough
2 parents 52ed396 + c60efaf commit 3fc8e8d

22 files changed

+56
-48
lines changed
 

‎CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ IF (PEDANTIC)
461461
# ADD_DEFINITIONS( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )
462462

463463
IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
464-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-overloaded-virtual")
464+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-overloaded-virtual -Wimplicit-fallthrough")
465465
ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
466466

467467
# add any extra CXXFLAGS flags set by user. can be -D CXX_EXTRA_FLAGS or environment variable

‎external/libdxfrw/intern/dwgutil.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#if __cplusplus >= 201500
2020
#define FALLTHROUGH [[fallthrough]];
2121
#elif defined(__clang__)
22-
#define FALLTHROUGH //[[clang::fallthrough]]
22+
#define FALLTHROUGH [[clang::fallthrough]];
2323
#elif defined(__GNUC__) && __GNUC__ >= 7
2424
#define FALLTHROUGH [[gnu::fallthrough]];
2525
#else
@@ -28,7 +28,8 @@
2828

2929
#include "qgslogger.h"
3030

31-
/** Utility function
31+
/**
32+
* Utility function
3233
* convert a int to string in hex
3334
**/
3435
namespace DRW

‎external/libdxfrw/libdxfrw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#if __cplusplus >= 201500
2828
#define FALLTHROUGH [[fallthrough]];
2929
#elif defined(__clang__)
30-
#define FALLTHROUGH //[[clang::fallthrough]]
30+
#define FALLTHROUGH [[clang::fallthrough]];
3131
#elif defined(__GNUC__) && __GNUC__ >= 7
3232
#define FALLTHROUGH [[gnu::fallthrough]];
3333
#else

‎src/core/dxf/qgsdxfexport.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,7 +3782,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
37823782
tempGeom = geom->segmentize();
37833783
if ( !tempGeom )
37843784
break;
3785-
FALLTHROUGH;
3785+
FALLTHROUGH
37863786
case QgsWkbTypes::LineString:
37873787
if ( !qgsDoubleNear( offset, 0.0 ) )
37883788
{
@@ -3802,7 +3802,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
38023802
tempGeom = geom->segmentize();
38033803
if ( !tempGeom )
38043804
break;
3805-
FALLTHROUGH;
3805+
FALLTHROUGH
38063806
case QgsWkbTypes::MultiLineString:
38073807
{
38083808
if ( !qgsDoubleNear( offset, 0.0 ) )
@@ -3828,7 +3828,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
38283828
tempGeom = geom->segmentize();
38293829
if ( !tempGeom )
38303830
break;
3831-
FALLTHROUGH;
3831+
FALLTHROUGH
38323832
case QgsWkbTypes::Polygon:
38333833
{
38343834
if ( !qgsDoubleNear( offset, 0.0 ) )
@@ -3888,7 +3888,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
38883888
tempGeom = tempGeom->segmentize();
38893889
if ( !tempGeom )
38903890
break;
3891-
FALLTHROUGH;
3891+
FALLTHROUGH
38923892
case QgsWkbTypes::Polygon:
38933893
writePolygon( tempGeom->coordinateSequence().at( 0 ), layer, QStringLiteral( "SOLID" ), brushColor );
38943894
break;

‎src/core/expression/qgsexpressionnodeimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const
193193
return QVariant( sL + sR );
194194
}
195195
//intentional fall-through
196-
FALLTHROUGH;
196+
FALLTHROUGH
197197
case boMinus:
198198
case boMul:
199199
case boDiv:

‎src/core/layout/qgsabstractreportsection.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ bool QgsAbstractReportSection::next()
221221

222222
// but if not, then the current section is a body
223223
mNextSection = Body;
224-
FALLTHROUGH;
224+
FALLTHROUGH
225225
}
226226

227227
case Body:
@@ -238,7 +238,7 @@ bool QgsAbstractReportSection::next()
238238
return true;
239239
}
240240

241-
FALLTHROUGH;
241+
FALLTHROUGH
242242
}
243243

244244
case Children:
@@ -284,7 +284,7 @@ bool QgsAbstractReportSection::next()
284284

285285
// all children and bodies have spent their content, so move to the footer
286286
mNextSection = Footer;
287-
FALLTHROUGH;
287+
FALLTHROUGH
288288
}
289289

290290
case Footer:
@@ -303,7 +303,7 @@ bool QgsAbstractReportSection::next()
303303
}
304304

305305
// if not, then we're all done
306-
FALLTHROUGH;
306+
FALLTHROUGH
307307
}
308308

309309
case End:

‎src/core/qgis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ typedef unsigned long long qgssize;
563563
#if __cplusplus >= 201500
564564
#define FALLTHROUGH [[fallthrough]];
565565
#elif defined(__clang__)
566-
#define FALLTHROUGH //[[clang::fallthrough]]
566+
#define FALLTHROUGH [[clang::fallthrough]];
567567
#elif defined(__GNUC__) && __GNUC__ >= 7
568568
#define FALLTHROUGH [[gnu::fallthrough]];
569569
#else

‎src/core/qgsogcutils.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
12121212
case QgsWkbTypes::MultiPoint25D:
12131213
hasZValue = true;
12141214
//intentional fall-through
1215-
FALLTHROUGH;
1215+
FALLTHROUGH
12161216
case QgsWkbTypes::MultiPoint:
12171217
{
12181218
QDomElement multiPointElem = doc.createElement( QStringLiteral( "gml:MultiPoint" ) );
@@ -1256,7 +1256,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
12561256
case QgsWkbTypes::LineString25D:
12571257
hasZValue = true;
12581258
//intentional fall-through
1259-
FALLTHROUGH;
1259+
FALLTHROUGH
12601260
case QgsWkbTypes::LineString:
12611261
{
12621262
QDomElement lineStringElem = doc.createElement( QStringLiteral( "gml:LineString" ) );
@@ -1298,7 +1298,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
12981298
case QgsWkbTypes::MultiLineString25D:
12991299
hasZValue = true;
13001300
//intentional fall-through
1301-
FALLTHROUGH;
1301+
FALLTHROUGH
13021302
case QgsWkbTypes::MultiLineString:
13031303
{
13041304
QDomElement multiLineStringElem = doc.createElement( QStringLiteral( "gml:MultiLineString" ) );
@@ -1355,7 +1355,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
13551355
case QgsWkbTypes::Polygon25D:
13561356
hasZValue = true;
13571357
//intentional fall-through
1358-
FALLTHROUGH;
1358+
FALLTHROUGH
13591359
case QgsWkbTypes::Polygon:
13601360
{
13611361
QDomElement polygonElem = doc.createElement( QStringLiteral( "gml:Polygon" ) );
@@ -1420,7 +1420,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
14201420
case QgsWkbTypes::MultiPolygon25D:
14211421
hasZValue = true;
14221422
//intentional fall-through
1423-
FALLTHROUGH;
1423+
FALLTHROUGH
14241424
case QgsWkbTypes::MultiPolygon:
14251425
{
14261426
QDomElement multiPolygonElem = doc.createElement( QStringLiteral( "gml:MultiPolygon" ) );

‎src/core/qgspointlocator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
357357
case QgsWkbTypes::LineString25D:
358358
hasZValue = true;
359359
//intentional fall-through
360-
FALLTHROUGH;
360+
FALLTHROUGH
361361
case QgsWkbTypes::LineString:
362362
{
363363
int nPoints;
@@ -391,7 +391,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
391391
case QgsWkbTypes::MultiLineString25D:
392392
hasZValue = true;
393393
//intentional fall-through
394-
FALLTHROUGH;
394+
FALLTHROUGH
395395
case QgsWkbTypes::MultiLineString:
396396
{
397397
int nLines;
@@ -432,7 +432,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
432432
case QgsWkbTypes::Polygon25D:
433433
hasZValue = true;
434434
//intentional fall-through
435-
FALLTHROUGH;
435+
FALLTHROUGH
436436
case QgsWkbTypes::Polygon:
437437
{
438438
int nRings;
@@ -473,7 +473,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
473473
case QgsWkbTypes::MultiPolygon25D:
474474
hasZValue = true;
475475
//intentional fall-through
476-
FALLTHROUGH;
476+
FALLTHROUGH
477477
case QgsWkbTypes::MultiPolygon:
478478
{
479479
int nPolygons;

‎src/core/qgsrendercontext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ double QgsRenderContext::convertToPainterUnits( double size, QgsUnitTypes::Rende
273273
size = convertMetersToMapUnits( size );
274274
unit = QgsUnitTypes::RenderMapUnits;
275275
// Fall through to RenderMapUnits with size in meters converted to size in MapUnits
276-
FALLTHROUGH;
276+
FALLTHROUGH
277277
}
278278
case QgsUnitTypes::RenderMapUnits:
279279
{
@@ -323,7 +323,7 @@ double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUni
323323
{
324324
size = convertMetersToMapUnits( size );
325325
// Fall through to RenderMapUnits with values of meters converted to MapUnits
326-
FALLTHROUGH;
326+
FALLTHROUGH
327327
}
328328
case QgsUnitTypes::RenderMapUnits:
329329
{

‎src/core/qgstextrenderer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ void QgsTextRenderer::drawPart( const QRectF &rect, double rotation, HAlignment
18131813
if ( !format.buffer().enabled() )
18141814
break;
18151815
}
1816-
FALLTHROUGH;
1816+
FALLTHROUGH
18171817
case Text:
18181818
case Shadow:
18191819
{
@@ -1857,7 +1857,7 @@ void QgsTextRenderer::drawPart( QPointF origin, double rotation, QgsTextRenderer
18571857
if ( !format.buffer().enabled() )
18581858
break;
18591859
}
1860-
FALLTHROUGH;
1860+
FALLTHROUGH
18611861
case Text:
18621862
case Shadow:
18631863
{
@@ -2077,6 +2077,7 @@ void QgsTextRenderer::drawBackground( QgsRenderContext &context, QgsTextRenderer
20772077
component.origin.y() - height / 2.0 + originAdjust );
20782078
break;
20792079
}
2080+
break;
20802081
}
20812082

20822083
case Label:

‎src/core/qgsvectorlayer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,7 +3464,7 @@ QSet<QVariant> QgsVectorLayer::uniqueValues( int index, int limit ) const
34643464
uniqueValues = mDataProvider->uniqueValues( index, limit );
34653465
return uniqueValues;
34663466
}
3467-
FALLTHROUGH;
3467+
FALLTHROUGH
34683468
//we need to go through each feature
34693469
case QgsFields::OriginJoin:
34703470
case QgsFields::OriginExpression:
@@ -3561,7 +3561,7 @@ QStringList QgsVectorLayer::uniqueStringsMatching( int index, const QString &sub
35613561
{
35623562
return mDataProvider->uniqueStringsMatching( index, substring, limit, feedback );
35633563
}
3564-
FALLTHROUGH;
3564+
FALLTHROUGH
35653565
//we need to go through each feature
35663566
case QgsFields::OriginJoin:
35673567
case QgsFields::OriginExpression:
@@ -3654,7 +3654,7 @@ QVariant QgsVectorLayer::minimumValue( int index ) const
36543654
return mDataProvider->minimumValue( index );
36553655
}
36563656
}
3657-
FALLTHROUGH;
3657+
FALLTHROUGH
36583658
// no choice but to go through all features
36593659
case QgsFields::OriginExpression:
36603660
case QgsFields::OriginJoin:
@@ -3740,7 +3740,7 @@ QVariant QgsVectorLayer::maximumValue( int index ) const
37403740
return mDataProvider->maximumValue( index );
37413741
}
37423742

3743-
FALLTHROUGH;
3743+
FALLTHROUGH
37443744
//no choice but to go through each feature
37453745
case QgsFields::OriginJoin:
37463746
case QgsFields::OriginExpression:

‎src/core/symbology/qgssymbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
996996
break;
997997
}
998998

999-
FALLTHROUGH;
999+
FALLTHROUGH
10001000
}
10011001
default:
10021002
QgsDebugMsg( QString( "feature %1: unsupported wkb type %2/%3 for rendering" )

‎src/gui/qgspropertyoverridebutton.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &proper
119119
{
120120
case QgsPropertyDefinition::DataTypeBoolean:
121121
ts << tr( "boolean" );
122-
FALLTHROUGH;
122+
FALLTHROUGH
123123

124124
case QgsPropertyDefinition::DataTypeNumeric:
125125
ts << tr( "int" );
126126
ts << tr( "double" );
127-
FALLTHROUGH;
127+
FALLTHROUGH
128128

129129
case QgsPropertyDefinition::DataTypeString:
130130
ts << tr( "string" );

‎src/gui/symbology/qgssymbolslistwidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,20 @@ void QgsSymbolsListWidget::createAuxiliaryField()
175175
if ( markerSymbol )
176176
markerSymbol->setDataDefinedAngle( button->toProperty() );
177177
break;
178+
178179
case QgsSymbolLayer::PropertySize:
179180
if ( markerSymbol )
180181
{
181182
markerSymbol->setDataDefinedSize( button->toProperty() );
182183
markerSymbol->setScaleMethod( QgsSymbol::ScaleDiameter );
183184
}
184185
break;
186+
185187
case QgsSymbolLayer::PropertyStrokeWidth:
186188
if ( lineSymbol )
187189
lineSymbol->setDataDefinedWidth( button->toProperty() );
190+
break;
191+
188192
default:
189193
break;
190194
}

‎src/plugins/georeferencer/qgsgeorefplugingui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void QgsGeorefPluginGui::generateGDALScript()
395395
break;
396396
}
397397
}
398-
FALLTHROUGH;
398+
FALLTHROUGH
399399
default:
400400
mMessageBar->pushMessage( tr( "Invalid Transform" ), tr( "GDAL scripting is not supported for %1 transformation." )
401401
.arg( convertTransformEnumToString( mTransformParam ) )

‎src/plugins/grass/qgsgrassnewmapset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ int QgsGrassNewMapset::nextId() const
322322
id = MapSet;
323323
break;
324324
}
325-
FALLTHROUGH;
325+
FALLTHROUGH
326326
case Database:
327327
case Crs:
328328
case Region:

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,8 @@ bool QgsOgrProvider::addAttributeOGRLevel( const QgsField &field, bool &ignoreEr
16191619
{
16201620
case QVariant::Bool:
16211621
OGR_Fld_SetSubType( fielddefn.get(), OFSTBoolean );
1622+
break;
1623+
16221624
default:
16231625
break;
16241626
}

‎src/providers/oracle/qgsoracleprovider.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
18411841
case QgsWkbTypes::Point25D:
18421842
case QgsWkbTypes::PointZ:
18431843
dim = 3;
1844-
FALLTHROUGH;
1844+
FALLTHROUGH
18451845

18461846
case QgsWkbTypes::Point:
18471847
g.srid = mSrid;
@@ -1856,7 +1856,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
18561856
case QgsWkbTypes::LineStringZ:
18571857
case QgsWkbTypes::MultiLineStringZ:
18581858
dim = 3;
1859-
FALLTHROUGH;
1859+
FALLTHROUGH
18601860

18611861
case QgsWkbTypes::LineString:
18621862
case QgsWkbTypes::MultiLineString:
@@ -1895,7 +1895,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
18951895
case QgsWkbTypes::PolygonZ:
18961896
case QgsWkbTypes::MultiPolygonZ:
18971897
dim = 3;
1898-
FALLTHROUGH;
1898+
FALLTHROUGH
18991899

19001900
case QgsWkbTypes::Polygon:
19011901
case QgsWkbTypes::MultiPolygon:
@@ -1937,7 +1937,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
19371937
case QgsWkbTypes::MultiPoint25D:
19381938
case QgsWkbTypes::MultiPointZ:
19391939
dim = 3;
1940-
FALLTHROUGH;
1940+
FALLTHROUGH
19411941

19421942
case QgsWkbTypes::MultiPoint:
19431943
{

0 commit comments

Comments
 (0)
Please sign in to comment.