Skip to content
Permalink
Browse files

[travis] Warn on unintentional switch fallthrough

Intentional fallthrough should be annotated with

"FALLTHROUGH;"
  • Loading branch information
nyalldawson committed Jan 25, 2016
1 parent f6c0d8d commit cf3c55bdfcafb6dd3fd99884c3211184defa11eb
@@ -1,6 +1,8 @@
mkdir build
cd build

CLANG_WARNINGS="-Wimplicit-fallthrough"

cmake -DWITH_SERVER=ON \
-DWITH_STAGED_PLUGINS=ON \
-DWITH_GRASS=ON \
@@ -13,4 +15,5 @@ cmake -DWITH_SERVER=ON \
-DWITH_PYSPATIALITE=ON \
-DGRASS_PREFIX7=/usr/lib/grass70 \
-DGRASS_INCLUDE_DIR7=/usr/lib/grass70/include \
-DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \
..
@@ -117,6 +117,7 @@ int QgsInterpolator::addVerticesToCache( const QgsGeometry *geom, bool zCoord, d
case QGis::WKBPoint25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBPoint:
{
currentWkbPtr >> theVertex.x >> theVertex.y;
@@ -134,6 +135,7 @@ int QgsInterpolator::addVerticesToCache( const QgsGeometry *geom, bool zCoord, d
case QGis::WKBLineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBLineString:
{
int nPoints;
@@ -208,6 +208,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
{
case QGis::WKBPoint25D:
hasZValue = true;
FALLTHROUGH;
case QGis::WKBPoint:
{
currentWkbPtr >> x >> y;
@@ -228,6 +229,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
}
case QGis::WKBMultiPoint25D:
hasZValue = true;
FALLTHROUGH;
case QGis::WKBMultiPoint:
{
int nPoints;
@@ -249,6 +251,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
}
case QGis::WKBLineString25D:
hasZValue = true;
FALLTHROUGH;
case QGis::WKBLineString:
{
if ( type != POINTS )
@@ -288,6 +291,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
}
case QGis::WKBMultiLineString25D:
hasZValue = true;
FALLTHROUGH;
case QGis::WKBMultiLineString:
{
int nLines;
@@ -331,6 +335,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
}
case QGis::WKBPolygon25D:
hasZValue = true;
FALLTHROUGH;
case QGis::WKBPolygon:
{
int nRings;
@@ -376,6 +381,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT

case QGis::WKBMultiPolygon25D:
hasZValue = true;
FALLTHROUGH;
case QGis::WKBMultiPolygon:
{
int nPolys;
@@ -230,6 +230,7 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
case QGis::UnknownUnit:
myScaleBarUnitLabel = tr( " unknown" );
//intentional fall-through
FALLTHROUGH;
default:
QgsDebugMsg( QString( "Error: not picked up map units - actual value = %1" ).arg( myMapUnits ) );
}
@@ -438,6 +438,7 @@ void QgsLabelPropertyDialog::enableDataDefinedWidgets( QgsVectorLayer* vlayer )
break;
case QgsPalLayerSettings::Size:
mFontSizeSpinBox->setEnabled( true );
break;
default:
break;
}
@@ -414,3 +414,9 @@ typedef unsigned long long qgssize;
#endif
#endif
#endif

#if defined(__clang__)
#define FALLTHROUGH [[clang::fallthrough]]
#else
#define FALLTHROUGH
#endif
@@ -1073,6 +1073,7 @@ QString QgsDistanceArea::textUnit( double value, int decimals, QGis::UnitType u,
case QGis::UnknownUnit:
unitLabel = QObject::tr( " unknown" );
//intentional fall-through
FALLTHROUGH;
default:
QgsDebugMsg( QString( "Error: not picked up map units - actual value = %1" ).arg( u ) );
}
@@ -3640,6 +3640,7 @@ QVariant QgsExpression::NodeBinaryOperator::eval( QgsExpression *parent, const Q
return QVariant( sL + sR );
}
//intentional fall-through
FALLTHROUGH;
case boMinus:
case boMul:
case boDiv:
@@ -605,6 +605,7 @@ const unsigned char* QgsLabel::labelPoint( labelpoint& point, const unsigned cha
case QGis::WKBLineString25D:
dims = 3;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBLineString: // Line center
{
#ifndef QT_NO_DEBUG
@@ -656,6 +657,7 @@ const unsigned char* QgsLabel::labelPoint( labelpoint& point, const unsigned cha
case QGis::WKBPolygon25D:
dims = 3;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBPolygon: // centroid of outer ring
{
#ifndef QT_NO_DEBUG
@@ -1125,6 +1125,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry* geometry, QDomDocumen
case QGis::WKBMultiPoint25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBMultiPoint:
{
QDomElement multiPointElem = doc.createElement( "gml:MultiPoint" );
@@ -1158,6 +1159,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry* geometry, QDomDocumen
case QGis::WKBLineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBLineString:
{
QDomElement lineStringElem = doc.createElement( "gml:LineString" );
@@ -1192,6 +1194,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry* geometry, QDomDocumen
case QGis::WKBMultiLineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBMultiLineString:
{
QDomElement multiLineStringElem = doc.createElement( "gml:MultiLineString" );
@@ -1238,6 +1241,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry* geometry, QDomDocumen
case QGis::WKBPolygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBPolygon:
{
QDomElement polygonElem = doc.createElement( "gml:Polygon" );
@@ -1295,6 +1299,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry* geometry, QDomDocumen
case QGis::WKBMultiPolygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBMultiPolygon:
{
QDomElement multiPolygonElem = doc.createElement( "gml:MultiPolygon" );
@@ -332,6 +332,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry* geom, co
case QGis::WKBLineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBLineString:
{
int nPoints;
@@ -365,6 +366,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry* geom, co
case QGis::WKBMultiLineString25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBMultiLineString:
{
int nLines;
@@ -405,6 +407,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry* geom, co
case QGis::WKBPolygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBPolygon:
{
int nRings;
@@ -445,6 +448,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry* geom, co
case QGis::WKBMultiPolygon25D:
hasZValue = true;
//intentional fall-through
FALLTHROUGH;
case QGis::WKBMultiPolygon:
{
int nPolygons;
@@ -400,6 +400,7 @@ void QgsGeorefPluginGui::generateGDALScript()
break;
}
}
FALLTHROUGH;
default:
mMessageBar->pushMessage( tr( "Invalid Transform" ), tr( "GDAL scripting is not supported for %1 transformation." )
.arg( convertTransformEnumToString( mTransformParam ) )
@@ -17,6 +17,7 @@
#include "qgsgrassnewmapset.h"
#include "qgsgrassplugin.h"
#include "qgsgrass.h"
#include "qgis.h"

#include "qgisinterface.h"
#include "qgsapplication.h"
@@ -298,6 +299,7 @@ int QgsGrassNewMapset::nextId() const
id = MAPSET;
break;
}
FALLTHROUGH;
case DATABASE:
case CRS:
case REGION:
@@ -1497,36 +1497,42 @@ void QgsMssqlProvider::mssqlWkbTypeAndDimension( QGis::WkbType wkbType, QString
{
case QGis::WKBPoint25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBPoint:
geometryType = "POINT";
break;

case QGis::WKBLineString25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBLineString:
geometryType = "LINESTRING";
break;

case QGis::WKBPolygon25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBPolygon:
geometryType = "POLYGON";
break;

case QGis::WKBMultiPoint25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiPoint:
geometryType = "MULTIPOINT";
break;

case QGis::WKBMultiLineString25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiLineString:
geometryType = "MULTILINESTRING";
break;

case QGis::WKBMultiPolygon25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiPolygon:
geometryType = "MULTIPOLYGON";
break;
@@ -1259,6 +1259,7 @@ qint64 QgsPostgresConn::getBinaryInt( QgsPostgresResult &queryResult, int row, i
default:
QgsDebugMsg( QString( "unexpected size %1" ).arg( s ) );
//intentional fall-through
FALLTHROUGH;
case 4:
oid = *( quint32 * )p;
if ( mSwapEndian )
@@ -1466,36 +1467,42 @@ void QgsPostgresConn::postgisWkbType( QGis::WkbType wkbType, QString &geometryTy
{
case QGis::WKBPoint25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBPoint:
geometryType = "POINT";
break;

case QGis::WKBLineString25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBLineString:
geometryType = "LINESTRING";
break;

case QGis::WKBPolygon25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBPolygon:
geometryType = "POLYGON";
break;

case QGis::WKBMultiPoint25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiPoint:
geometryType = "MULTIPOINT";
break;

case QGis::WKBMultiLineString25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiLineString:
geometryType = "MULTILINESTRING";
break;

case QGis::WKBMultiPolygon25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiPolygon:
geometryType = "MULTIPOLYGON";
break;
@@ -234,36 +234,42 @@ QgsSpatiaLiteProvider::createEmptyLayer(
{
case QGis::WKBPoint25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBPoint:
geometryType = "POINT";
break;

case QGis::WKBLineString25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBLineString:
geometryType = "LINESTRING";
break;

case QGis::WKBPolygon25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBPolygon:
geometryType = "POLYGON";
break;

case QGis::WKBMultiPoint25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiPoint:
geometryType = "MULTIPOINT";
break;

case QGis::WKBMultiLineString25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiLineString:
geometryType = "MULTILINESTRING";
break;

case QGis::WKBMultiPolygon25D:
dim = 3;
FALLTHROUGH;
case QGis::WKBMultiPolygon:
geometryType = "MULTIPOLYGON";
break;

0 comments on commit cf3c55b

Please sign in to comment.
You can’t perform that action at this time.