Skip to content

Commit

Permalink
Merge pull request #7530 from m-kuhn/implicit-fallthrough
Browse files Browse the repository at this point in the history
Enable -Wimplicit-fallthrough
  • Loading branch information
m-kuhn committed Aug 6, 2018
2 parents 52ed396 + c60efaf commit 3fc8e8d
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -461,7 +461,7 @@ IF (PEDANTIC)
# ADD_DEFINITIONS( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )

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

# add any extra CXXFLAGS flags set by user. can be -D CXX_EXTRA_FLAGS or environment variable
Expand Down
5 changes: 3 additions & 2 deletions external/libdxfrw/intern/dwgutil.cpp
Expand Up @@ -19,7 +19,7 @@
#if __cplusplus >= 201500
#define FALLTHROUGH [[fallthrough]];
#elif defined(__clang__)
#define FALLTHROUGH //[[clang::fallthrough]]
#define FALLTHROUGH [[clang::fallthrough]];
#elif defined(__GNUC__) && __GNUC__ >= 7
#define FALLTHROUGH [[gnu::fallthrough]];
#else
Expand All @@ -28,7 +28,8 @@

#include "qgslogger.h"

/** Utility function
/**
* Utility function
* convert a int to string in hex
**/
namespace DRW
Expand Down
2 changes: 1 addition & 1 deletion external/libdxfrw/libdxfrw.cpp
Expand Up @@ -27,7 +27,7 @@
#if __cplusplus >= 201500
#define FALLTHROUGH [[fallthrough]];
#elif defined(__clang__)
#define FALLTHROUGH //[[clang::fallthrough]]
#define FALLTHROUGH [[clang::fallthrough]];
#elif defined(__GNUC__) && __GNUC__ >= 7
#define FALLTHROUGH [[gnu::fallthrough]];
#else
Expand Down
8 changes: 4 additions & 4 deletions src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -3782,7 +3782,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
tempGeom = geom->segmentize();
if ( !tempGeom )
break;
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::LineString:
if ( !qgsDoubleNear( offset, 0.0 ) )
{
Expand All @@ -3802,7 +3802,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
tempGeom = geom->segmentize();
if ( !tempGeom )
break;
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::MultiLineString:
{
if ( !qgsDoubleNear( offset, 0.0 ) )
Expand All @@ -3828,7 +3828,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
tempGeom = geom->segmentize();
if ( !tempGeom )
break;
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::Polygon:
{
if ( !qgsDoubleNear( offset, 0.0 ) )
Expand Down Expand Up @@ -3888,7 +3888,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
tempGeom = tempGeom->segmentize();
if ( !tempGeom )
break;
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::Polygon:
writePolygon( tempGeom->coordinateSequence().at( 0 ), layer, QStringLiteral( "SOLID" ), brushColor );
break;
Expand Down
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressionnodeimpl.cpp
Expand Up @@ -193,7 +193,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const
return QVariant( sL + sR );
}
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case boMinus:
case boMul:
case boDiv:
Expand Down
8 changes: 4 additions & 4 deletions src/core/layout/qgsabstractreportsection.cpp
Expand Up @@ -221,7 +221,7 @@ bool QgsAbstractReportSection::next()

// but if not, then the current section is a body
mNextSection = Body;
FALLTHROUGH;
FALLTHROUGH
}

case Body:
Expand All @@ -238,7 +238,7 @@ bool QgsAbstractReportSection::next()
return true;
}

FALLTHROUGH;
FALLTHROUGH
}

case Children:
Expand Down Expand Up @@ -284,7 +284,7 @@ bool QgsAbstractReportSection::next()

// all children and bodies have spent their content, so move to the footer
mNextSection = Footer;
FALLTHROUGH;
FALLTHROUGH
}

case Footer:
Expand All @@ -303,7 +303,7 @@ bool QgsAbstractReportSection::next()
}

// if not, then we're all done
FALLTHROUGH;
FALLTHROUGH
}

case End:
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgis.h
Expand Up @@ -563,7 +563,7 @@ typedef unsigned long long qgssize;
#if __cplusplus >= 201500
#define FALLTHROUGH [[fallthrough]];
#elif defined(__clang__)
#define FALLTHROUGH //[[clang::fallthrough]]
#define FALLTHROUGH [[clang::fallthrough]];
#elif defined(__GNUC__) && __GNUC__ >= 7
#define FALLTHROUGH [[gnu::fallthrough]];
#else
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgsogcutils.cpp
Expand Up @@ -1212,7 +1212,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
case QgsWkbTypes::MultiPoint25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::MultiPoint:
{
QDomElement multiPointElem = doc.createElement( QStringLiteral( "gml:MultiPoint" ) );
Expand Down Expand Up @@ -1256,7 +1256,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
case QgsWkbTypes::LineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::LineString:
{
QDomElement lineStringElem = doc.createElement( QStringLiteral( "gml:LineString" ) );
Expand Down Expand Up @@ -1298,7 +1298,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
case QgsWkbTypes::MultiLineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::MultiLineString:
{
QDomElement multiLineStringElem = doc.createElement( QStringLiteral( "gml:MultiLineString" ) );
Expand Down Expand Up @@ -1355,7 +1355,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
case QgsWkbTypes::Polygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::Polygon:
{
QDomElement polygonElem = doc.createElement( QStringLiteral( "gml:Polygon" ) );
Expand Down Expand Up @@ -1420,7 +1420,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocumen
case QgsWkbTypes::MultiPolygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::MultiPolygon:
{
QDomElement multiPolygonElem = doc.createElement( QStringLiteral( "gml:MultiPolygon" ) );
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgspointlocator.cpp
Expand Up @@ -357,7 +357,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
case QgsWkbTypes::LineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::LineString:
{
int nPoints;
Expand Down Expand Up @@ -391,7 +391,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
case QgsWkbTypes::MultiLineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::MultiLineString:
{
int nLines;
Expand Down Expand Up @@ -432,7 +432,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
case QgsWkbTypes::Polygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::Polygon:
{
int nRings;
Expand Down Expand Up @@ -473,7 +473,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
case QgsWkbTypes::MultiPolygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
FALLTHROUGH
case QgsWkbTypes::MultiPolygon:
{
int nPolygons;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsrendercontext.cpp
Expand Up @@ -273,7 +273,7 @@ double QgsRenderContext::convertToPainterUnits( double size, QgsUnitTypes::Rende
size = convertMetersToMapUnits( size );
unit = QgsUnitTypes::RenderMapUnits;
// Fall through to RenderMapUnits with size in meters converted to size in MapUnits
FALLTHROUGH;
FALLTHROUGH
}
case QgsUnitTypes::RenderMapUnits:
{
Expand Down Expand Up @@ -323,7 +323,7 @@ double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUni
{
size = convertMetersToMapUnits( size );
// Fall through to RenderMapUnits with values of meters converted to MapUnits
FALLTHROUGH;
FALLTHROUGH
}
case QgsUnitTypes::RenderMapUnits:
{
Expand Down
5 changes: 3 additions & 2 deletions src/core/qgstextrenderer.cpp
Expand Up @@ -1813,7 +1813,7 @@ void QgsTextRenderer::drawPart( const QRectF &rect, double rotation, HAlignment
if ( !format.buffer().enabled() )
break;
}
FALLTHROUGH;
FALLTHROUGH
case Text:
case Shadow:
{
Expand Down Expand Up @@ -1857,7 +1857,7 @@ void QgsTextRenderer::drawPart( QPointF origin, double rotation, QgsTextRenderer
if ( !format.buffer().enabled() )
break;
}
FALLTHROUGH;
FALLTHROUGH
case Text:
case Shadow:
{
Expand Down Expand Up @@ -2077,6 +2077,7 @@ void QgsTextRenderer::drawBackground( QgsRenderContext &context, QgsTextRenderer
component.origin.y() - height / 2.0 + originAdjust );
break;
}
break;
}

case Label:
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -3464,7 +3464,7 @@ QSet<QVariant> QgsVectorLayer::uniqueValues( int index, int limit ) const
uniqueValues = mDataProvider->uniqueValues( index, limit );
return uniqueValues;
}
FALLTHROUGH;
FALLTHROUGH
//we need to go through each feature
case QgsFields::OriginJoin:
case QgsFields::OriginExpression:
Expand Down Expand Up @@ -3561,7 +3561,7 @@ QStringList QgsVectorLayer::uniqueStringsMatching( int index, const QString &sub
{
return mDataProvider->uniqueStringsMatching( index, substring, limit, feedback );
}
FALLTHROUGH;
FALLTHROUGH
//we need to go through each feature
case QgsFields::OriginJoin:
case QgsFields::OriginExpression:
Expand Down Expand Up @@ -3654,7 +3654,7 @@ QVariant QgsVectorLayer::minimumValue( int index ) const
return mDataProvider->minimumValue( index );
}
}
FALLTHROUGH;
FALLTHROUGH
// no choice but to go through all features
case QgsFields::OriginExpression:
case QgsFields::OriginJoin:
Expand Down Expand Up @@ -3740,7 +3740,7 @@ QVariant QgsVectorLayer::maximumValue( int index ) const
return mDataProvider->maximumValue( index );
}

FALLTHROUGH;
FALLTHROUGH
//no choice but to go through each feature
case QgsFields::OriginJoin:
case QgsFields::OriginExpression:
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology/qgssymbol.cpp
Expand Up @@ -996,7 +996,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
break;
}

FALLTHROUGH;
FALLTHROUGH
}
default:
QgsDebugMsg( QString( "feature %1: unsupported wkb type %2/%3 for rendering" )
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgspropertyoverridebutton.cpp
Expand Up @@ -119,12 +119,12 @@ void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &proper
{
case QgsPropertyDefinition::DataTypeBoolean:
ts << tr( "boolean" );
FALLTHROUGH;
FALLTHROUGH

case QgsPropertyDefinition::DataTypeNumeric:
ts << tr( "int" );
ts << tr( "double" );
FALLTHROUGH;
FALLTHROUGH

case QgsPropertyDefinition::DataTypeString:
ts << tr( "string" );
Expand Down
4 changes: 4 additions & 0 deletions src/gui/symbology/qgssymbolslistwidget.cpp
Expand Up @@ -175,16 +175,20 @@ void QgsSymbolsListWidget::createAuxiliaryField()
if ( markerSymbol )
markerSymbol->setDataDefinedAngle( button->toProperty() );
break;

case QgsSymbolLayer::PropertySize:
if ( markerSymbol )
{
markerSymbol->setDataDefinedSize( button->toProperty() );
markerSymbol->setScaleMethod( QgsSymbol::ScaleDiameter );
}
break;

case QgsSymbolLayer::PropertyStrokeWidth:
if ( lineSymbol )
lineSymbol->setDataDefinedWidth( button->toProperty() );
break;

default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsgeorefplugingui.cpp
Expand Up @@ -395,7 +395,7 @@ void QgsGeorefPluginGui::generateGDALScript()
break;
}
}
FALLTHROUGH;
FALLTHROUGH
default:
mMessageBar->pushMessage( tr( "Invalid Transform" ), tr( "GDAL scripting is not supported for %1 transformation." )
.arg( convertTransformEnumToString( mTransformParam ) )
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassnewmapset.cpp
Expand Up @@ -322,7 +322,7 @@ int QgsGrassNewMapset::nextId() const
id = MapSet;
break;
}
FALLTHROUGH;
FALLTHROUGH
case Database:
case Crs:
case Region:
Expand Down
2 changes: 2 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1619,6 +1619,8 @@ bool QgsOgrProvider::addAttributeOGRLevel( const QgsField &field, bool &ignoreEr
{
case QVariant::Bool:
OGR_Fld_SetSubType( fielddefn.get(), OFSTBoolean );
break;

default:
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1841,7 +1841,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
case QgsWkbTypes::Point25D:
case QgsWkbTypes::PointZ:
dim = 3;
FALLTHROUGH;
FALLTHROUGH

case QgsWkbTypes::Point:
g.srid = mSrid;
Expand All @@ -1856,7 +1856,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
case QgsWkbTypes::LineStringZ:
case QgsWkbTypes::MultiLineStringZ:
dim = 3;
FALLTHROUGH;
FALLTHROUGH

case QgsWkbTypes::LineString:
case QgsWkbTypes::MultiLineString:
Expand Down Expand Up @@ -1895,7 +1895,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
case QgsWkbTypes::PolygonZ:
case QgsWkbTypes::MultiPolygonZ:
dim = 3;
FALLTHROUGH;
FALLTHROUGH

case QgsWkbTypes::Polygon:
case QgsWkbTypes::MultiPolygon:
Expand Down Expand Up @@ -1937,7 +1937,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry
case QgsWkbTypes::MultiPoint25D:
case QgsWkbTypes::MultiPointZ:
dim = 3;
FALLTHROUGH;
FALLTHROUGH

case QgsWkbTypes::MultiPoint:
{
Expand Down

0 comments on commit 3fc8e8d

Please sign in to comment.