diff --git a/.ci/travis/linux/install.sh b/.ci/travis/linux/install.sh index 111c3ffa86c..0b68b220d72 100755 --- a/.ci/travis/linux/install.sh +++ b/.ci/travis/linux/install.sh @@ -52,7 +52,6 @@ CMAKE_FLAGS=" -DWITH_QWTPOLAR=OFF -DWITH_APIDOC=OFF -DWITH_ASTYLE=OFF - -DWITH_INTERNAL_YAML=OFF -DDISABLE_DEPRECATED=ON -DCXX_EXTRA_FLAGS=${CLANG_WARNINGS} " diff --git a/CMakeLists.txt b/CMakeLists.txt index 117eb8d8471..66b9ec14c13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ MESSAGE(STATUS "QGIS version: ${COMPLETE_VERSION} ${RELEASE_NAME} (${QGIS_VERSIO ############################################################# # CMake settings -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6) +CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0) SET(CMAKE_COLOR_MAKEFILE ON) diff --git a/cmake/SIPMacros.cmake b/cmake/SIPMacros.cmake index 501eb6afa4c..e58fb409666 100644 --- a/cmake/SIPMacros.cmake +++ b/cmake/SIPMacros.cmake @@ -37,7 +37,7 @@ SET(SIP_INCLUDES) SET(SIP_TAGS) -SET(SIP_CONCAT_PARTS 8) +SET(SIP_CONCAT_PARTS 10) SET(SIP_DISABLE_FEATURES) SET(SIP_EXTRA_OPTIONS) SET(SIP_EXTRA_OBJECTS) @@ -79,10 +79,13 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP CPP_FILES) # Suppress warnings IF(PEDANTIC) IF(MSVC) - # 4996 deprecation warnings (bindings re-export deprecated methods) - # 4701 potentially uninitialized variable used (sip generated code) - # 4702 unreachable code (sip generated code) - ADD_DEFINITIONS( /wd4996 /wd4701 /wd4702 ) + ADD_DEFINITIONS( + /wd4189 # local variable is initialized but not referenced + /wd4996 # deprecation warnings (bindings re-export deprecated methods) + /wd4701 # potentially uninitialized variable used (sip generated code) + /wd4702 # unreachable code (sip generated code) + /wd4703 # potentially uninitialized local pointer variable 'sipType' used + ) ELSE(MSVC) # disable all warnings ADD_DEFINITIONS( -w -Wno-deprecated-declarations ) diff --git a/doc/overview.t2t b/doc/overview.t2t index bed50d9a948..1dfb2f588d6 100644 --- a/doc/overview.t2t +++ b/doc/overview.t2t @@ -8,7 +8,7 @@ Following a summary of the required dependencies for building: Required build tools: -- CMake >= 2.8.6 +- CMake >= 3.0.0 - Flex >= 2.5.6 - Bison >= 2.4 - diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index 4ab99eee6dc..ce148fe136f 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -577,7 +577,6 @@ Unregister a previously registered action. (e.g. when plugin is going to be unlo %End - virtual QMenu *projectMenu() = 0; %Docstring :rtype: QMenu diff --git a/scripts/sipify.pl b/scripts/sipify.pl index 3bdea4ee9ed..0aa88fbf408 100755 --- a/scripts/sipify.pl +++ b/scripts/sipify.pl @@ -463,8 +463,8 @@ while ($LINE_IDX < $LINE_COUNT){ if ( $LINE =~ m/^\s*friend class \w+/ ){ next; } - # Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET - if ($LINE =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO|DECL_DEPRECATED).*?$/){ + # Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET etc. + if ($LINE =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO|DECL_DEPRECATED|NOWARN_DEPRECATED_(PUSH|POP)).*?$/){ next; } diff --git a/scripts/spell_check/check_spelling.sh b/scripts/spell_check/check_spelling.sh index 9b6e1b9c933..ea435ed890d 100755 --- a/scripts/spell_check/check_spelling.sh +++ b/scripts/spell_check/check_spelling.sh @@ -82,7 +82,7 @@ declare -A GLOBREP_IGNORE=() ERRORFOUND=NO for I in $(seq -f '%02g' 0 $(($SPLIT-1)) ) ; do - ( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && printf "Progress: %d/%d\n" $I $SPLIT + ( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && printf "Progress: %d/%d\n" $(( I + 1 )) $SPLIT SPELLFILE=spelling$I~ # if correction contains an uppercase letter and is the same as the error character wise, this means that the error is searched as a full word and case sensitive (not incorporated in a bigger one) diff --git a/src/app/dwg/libdxfrw/intern/dwgutil.cpp b/src/app/dwg/libdxfrw/intern/dwgutil.cpp index 3213e5726a7..ad8ca31c977 100644 --- a/src/app/dwg/libdxfrw/intern/dwgutil.cpp +++ b/src/app/dwg/libdxfrw/intern/dwgutil.cpp @@ -16,6 +16,16 @@ #include "rscodec.h" #include "../libdwgr.h" +#if __cplusplus >= 201500 +#define FALLTHROUGH [[fallthrough]]; +#elif defined(__clang__) +#define FALLTHROUGH //[[clang::fallthrough]] +#elif defined(__GNUC__) && __GNUC__ >= 7 +#define FALLTHROUGH [[gnu::fallthrough]]; +#else +#define FALLTHROUGH +#endif + #include "qgslogger.h" /** Utility function @@ -486,6 +496,9 @@ void dwgCompressor::copyCompBytes21( duint8 *cbuf, duint8 *dbuf, duint32 l, duin for ( int i = 1; i < 5; i++ ) dbuf[dix++] = cbuf[six + i]; dbuf[dix] = cbuf[six]; + + FALLTHROUGH + case 8: //OK for ( int i = 0; i < 8; i++ ) //RLZ 4[0],4[4] or 4[4],4[0] dbuf[dix++] = cbuf[six++]; diff --git a/src/app/dwg/libdxfrw/libdxfrw.cpp b/src/app/dwg/libdxfrw/libdxfrw.cpp index 1a48bc0b383..4a39578d60a 100644 --- a/src/app/dwg/libdxfrw/libdxfrw.cpp +++ b/src/app/dwg/libdxfrw/libdxfrw.cpp @@ -24,6 +24,16 @@ #include "qgslogger.h" +#if __cplusplus >= 201500 +#define FALLTHROUGH [[fallthrough]]; +#elif defined(__clang__) +#define FALLTHROUGH //[[clang::fallthrough]] +#elif defined(__GNUC__) && __GNUC__ >= 7 +#define FALLTHROUGH [[gnu::fallthrough]]; +#else +#define FALLTHROUGH +#endif + #define FIRSTHANDLE 48 #if 0 @@ -3047,6 +3057,8 @@ bool dxfRW::processPolyline() { processVertex( &pl ); } + + FALLTHROUGH } default: pl.parseCode( code, reader ); @@ -3079,6 +3091,8 @@ bool dxfRW::processVertex( DRW_Polyline *pl ) { v = new DRW_Vertex(); //another vertex } + + FALLTHROUGH } default: v->parseCode( code, reader ); diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index 0459affbb97..57217a9b5ae 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -1395,7 +1395,7 @@ void QgsDwgImporter::addEllipse( const DRW_Ellipse &data ) bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoundCurve &cc ) { - int vertexnum = data.vertlist.size(); + size_t vertexnum = data.vertlist.size(); if ( vertexnum == 0 ) { QgsDebugMsg( "polyline without points" ); @@ -1407,7 +1407,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun std::vector::size_type n = data.flags & 1 ? vertexnum + 1 : vertexnum; for ( std::vector::size_type i = 0; i < n; i++ ) { - int i0 = i % vertexnum; + size_t i0 = i % vertexnum; Q_ASSERT( data.vertlist[i0] != nullptr ); QgsDebugMsgLevel( QString( "%1: %2,%3 bulge:%4" ).arg( i ).arg( data.vertlist[i0]->x ).arg( data.vertlist[i0]->y ).arg( data.vertlist[i0]->bulge ), 5 ); @@ -1439,7 +1439,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun if ( hasBulge && i < n - 1 ) { - int i1 = ( i + 1 ) % vertexnum; + size_t i1 = ( i + 1 ) % vertexnum; double a = 2.0 * atan( data.vertlist[i]->bulge ); double dx = data.vertlist[i1]->x - data.vertlist[i0]->x; @@ -1461,7 +1461,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) { - int vertexnum = data.vertlist.size(); + size_t vertexnum = data.vertlist.size(); if ( vertexnum == 0 ) { QgsDebugMsg( "LWPolyline without vertices" ); @@ -1476,8 +1476,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) std::vector::size_type n = data.flags & 1 ? vertexnum : vertexnum - 1; for ( std::vector::size_type i = 0; i < n; i++ ) { - int i0 = i % vertexnum; - int i1 = ( i + 1 ) % vertexnum; + size_t i0 = i % vertexnum; + size_t i1 = ( i + 1 ) % vertexnum; QgsPoint p0( QgsWkbTypes::PointZ, data.vertlist[i0]->x, data.vertlist[i0]->y, data.elevation ); QgsPoint p1( QgsWkbTypes::PointZ, data.vertlist[i1]->x, data.vertlist[i1]->y, data.elevation ); @@ -1660,7 +1660,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) { - int vertexnum = data.vertlist.size(); + size_t vertexnum = data.vertlist.size(); if ( vertexnum == 0 ) { QgsDebugMsg( "Polyline without vertices" ); @@ -1675,8 +1675,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) std::vector::size_type n = data.flags & 1 ? vertexnum : vertexnum - 1; for ( std::vector::size_type i = 0; i < n; i++ ) { - int i0 = i % vertexnum; - int i1 = ( i + 1 ) % vertexnum; + size_t i0 = i % vertexnum; + size_t i1 = ( i + 1 ) % vertexnum; QgsPoint p0( QgsWkbTypes::PointZ, data.vertlist[i0]->basePoint.x, data.vertlist[i0]->basePoint.y, data.vertlist[i0]->basePoint.z ); QgsPoint p1( QgsWkbTypes::PointZ, data.vertlist[i1]->basePoint.x, data.vertlist[i1]->basePoint.y, data.vertlist[i1]->basePoint.z ); @@ -1906,24 +1906,24 @@ static std::vector knotu( const DRW_Spline &data, size_t num, size_t ord } } -static std::vector rbasis( int c, double t, int npts, +static std::vector rbasis( size_t c, double t, size_t npts, const std::vector &x, const std::vector &h ) { - int nplusc = npts + c; + size_t nplusc = npts + c; std::vector temp( nplusc, 0. ); // calculate the first order nonrational basis functions n[i] - for ( int i = 0; i < nplusc - 1; ++i ) + for ( size_t i = 0; i < nplusc - 1; ++i ) { if ( t >= x[i] && t < x[i + 1] ) temp[i] = 1; } // calculate the higher order nonrational base functions - for ( int k = 2; k <= c; ++k ) + for ( size_t k = 2; k <= c; ++k ) { - for ( int i = 0; i < nplusc - k; ++i ) + for ( size_t i = 0; i < nplusc - k; ++i ) { // if the lower order basis function is zero skip the calculation if ( temp[i] != 0 ) @@ -1941,7 +1941,7 @@ static std::vector rbasis( int c, double t, int npts, // calculate sum for denominator of rational basis functions double sum = 0.; - for ( int i = 0; i < npts; ++i ) + for ( size_t i = 0; i < npts; ++i ) { sum += temp[i] * h[i]; } @@ -1951,7 +1951,7 @@ static std::vector rbasis( int c, double t, int npts, // form rational basis functions and put in r vector if ( sum != 0.0 ) { - for ( int i = 0; i < npts; i++ ) + for ( size_t i = 0; i < npts; i++ ) { r[i] = ( temp[i] * h[i] ) / sum; } @@ -1969,7 +1969,7 @@ static void rbspline( const DRW_Spline &data, const std::vector &h, std::vector &p ) { - int nplusc = npts + k; + size_t nplusc = npts + k; // generate the open knot vector std::vector x( knot( data, npts, k ) ); diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index c23e6ac3586..ae6225b36cb 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -33,6 +33,7 @@ class QgisApp; * plugin. */ +Q_NOWARN_DEPRECATED_PUSH class APP_EXPORT QgisAppInterface : public QgisInterface { Q_OBJECT @@ -519,5 +520,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface //! Pointer to the PluginManagerInterface object QgsAppPluginManagerInterface pluginManagerIface; }; +Q_NOWARN_DEPRECATED_POP #endif //#define QGISAPPINTERFACE_H diff --git a/src/core/geometry/qgsgeometrymakevalid.cpp b/src/core/geometry/qgsgeometrymakevalid.cpp index 98a0df2b06c..275bc04c198 100644 --- a/src/core/geometry/qgsgeometrymakevalid.cpp +++ b/src/core/geometry/qgsgeometrymakevalid.cpp @@ -159,8 +159,10 @@ static GEOSGeometry *LWGEOM_GEOS_buildArea( const GEOSGeometry *geom_in, QString } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH errorMessage = QString( "GEOSPolygonize(): %1" ).arg( e.what() ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } // We should now have a collection @@ -505,9 +507,11 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH GEOSGeom_destroy_r( handle, geos_bound ); errorMessage = QString( "GEOSGeom_extractUniquePoints(): %1" ).arg( e.what() ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } try @@ -516,10 +520,12 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH GEOSGeom_destroy_r( handle, geos_bound ); GEOSGeom_destroy_r( handle, pi ); errorMessage = QString( "GEOSGeom_extractUniquePoints(): %1" ).arg( e.what() ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } try @@ -528,11 +534,13 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH GEOSGeom_destroy_r( handle, geos_bound ); GEOSGeom_destroy_r( handle, pi ); GEOSGeom_destroy_r( handle, po ); errorMessage = QString( "GEOSDifference(): %1" ).arg( e.what() ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } GEOSGeom_destroy_r( handle, pi ); @@ -547,9 +555,11 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH errorMessage = QString( "GEOSGeom_createEmptyPolygon(): %1" ).arg( e.what() ); GEOSGeom_destroy_r( handle, geos_cut_edges ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } // See if an area can be build with the remaining edges @@ -594,12 +604,14 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH // We did check for empty area already so // this must be some other error errorMessage = QString( "GEOSBoundary() threw an error: %1" ).arg( e.what() ); GEOSGeom_destroy_r( handle, new_area ); GEOSGeom_destroy_r( handle, geos_area ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } // Now symdif new and old area @@ -609,12 +621,14 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH GEOSGeom_destroy_r( handle, geos_cut_edges ); GEOSGeom_destroy_r( handle, new_area ); GEOSGeom_destroy_r( handle, new_area_bound ); GEOSGeom_destroy_r( handle, geos_area ); errorMessage = QString( "GEOSSymDifference() threw an error: %1" ).arg( e.what() ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } GEOSGeom_destroy_r( handle, geos_area ); @@ -636,11 +650,13 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH GEOSGeom_destroy_r( handle, geos_cut_edges ); GEOSGeom_destroy_r( handle, new_area_bound ); GEOSGeom_destroy_r( handle, geos_area ); errorMessage = QString( "GEOSDifference() threw an error: %1" ).arg( e.what() ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } GEOSGeom_destroy_r( handle, geos_cut_edges ); GEOSGeom_destroy_r( handle, new_area_bound ); @@ -688,9 +704,11 @@ static GEOSGeometry *LWGEOM_GEOS_makeValidPolygon( const GEOSGeometry *gin, QStr } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH errorMessage = QString( "GEOSGeom_createCollection() threw an error: %1" ).arg( e.what() ); // TODO: cleanup! return nullptr; + Q_NOWARN_UNREACHABLE_POP } } @@ -856,9 +874,11 @@ static GEOSGeometry *LWGEOM_GEOS_makeValid( const GEOSGeometry *gin, QString &er } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH // I don't think should ever happen errorMessage = QString( "GEOSisValid(): %1" ).arg( e.what() ); return nullptr; + Q_NOWARN_UNREACHABLE_POP } // make what we got valid diff --git a/src/core/gps/tok.c b/src/core/gps/tok.c index 0434eb56c9a..c0cf8ce9b86 100644 --- a/src/core/gps/tok.c +++ b/src/core/gps/tok.c @@ -26,6 +26,14 @@ //! \file tok.h +#if defined(__clang__) +#define FALLTHROUGH //[[clang::fallthrough]] +#elif defined(__GNUC__) && __GNUC__ >= 7 +#define FALLTHROUGH __attribute__((fallthrough)); +#else +#define FALLTHROUGH +#endif + #include "tok.h" #include @@ -165,15 +173,21 @@ int nmea_scanf( const char *buff, int buff_sz, const char *format, ... ) width = 0; beg_fmt = format; tok_type = NMEA_TOKS_WIDTH; - //intentional fall-through + + FALLTHROUGH + case NMEA_TOKS_WIDTH: + { if ( isdigit( *format ) ) break; - { - tok_type = NMEA_TOKS_TYPE; - if ( format > beg_fmt ) - width = nmea_atoi( beg_fmt, ( int )( format - beg_fmt ), 10 ); - } + + tok_type = NMEA_TOKS_TYPE; + if ( format > beg_fmt ) + width = nmea_atoi( beg_fmt, ( int )( format - beg_fmt ), 10 ); + + FALLTHROUGH + } + case NMEA_TOKS_TYPE: beg_tok = buff; diff --git a/src/core/pal/geomfunction.cpp b/src/core/pal/geomfunction.cpp index a0cf1b25cee..b61b5d0e3f0 100644 --- a/src/core/pal/geomfunction.cpp +++ b/src/core/pal/geomfunction.cpp @@ -363,8 +363,10 @@ bool GeomFunction::containsCandidate( const GEOSPreparedGeometry *geom, double x } catch ( GEOSException &e ) { + Q_NOWARN_UNREACHABLE_PUSH QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) ); return false; + Q_NOWARN_UNREACHABLE_POP } } diff --git a/src/core/providers/memory/qgsmemoryproviderutils.cpp b/src/core/providers/memory/qgsmemoryproviderutils.cpp index cccc63c4cec..b0eb108be55 100644 --- a/src/core/providers/memory/qgsmemoryproviderutils.cpp +++ b/src/core/providers/memory/qgsmemoryproviderutils.cpp @@ -45,9 +45,9 @@ QString memoryLayerFieldType( QVariant::Type type ) return QStringLiteral( "datetime" ); default: - return QStringLiteral( "string" ); + break; } - return QStringLiteral( "string" ); // no warnings + return QStringLiteral( "string" ); } QgsVectorLayer *QgsMemoryProviderUtils::createMemoryLayer( const QString &name, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs ) diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index 460476ad70d..e5e7350c94a 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -232,7 +232,7 @@ QString qgsVsiPrefix( const QString &path ) uint qHash( const QVariant &variant ) { if ( !variant.isValid() || variant.isNull() ) - return -1; + return std::numeric_limits::max(); switch ( variant.type() ) { @@ -290,8 +290,8 @@ uint qHash( const QVariant &variant ) case QVariant::RegExp: return qHash( variant.toString() ); default: - return -1; + break; } - return -1; + return std::numeric_limits::max(); } diff --git a/src/core/qgis.h b/src/core/qgis.h index 313a16e9964..3cac2097084 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -356,20 +356,35 @@ typedef unsigned long long qgssize; #ifndef SIP_RUN #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__) + #define Q_NOWARN_DEPRECATED_PUSH \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\""); #define Q_NOWARN_DEPRECATED_POP \ _Pragma("GCC diagnostic pop"); +#define Q_NOWARN_UNREACHABLE_PUSH +#define Q_NOWARN_UNREACHABLE_POP + #elif defined(_MSC_VER) + #define Q_NOWARN_DEPRECATED_PUSH \ __pragma(warning(push)) \ __pragma(warning(disable:4996)) #define Q_NOWARN_DEPRECATED_POP \ __pragma(warning(pop)) +#define Q_NOWARN_UNREACHABLE_PUSH \ + __pragma(warning(push)) \ + __pragma(warning(disable:4702)) +#define Q_NOWARN_UNREACHABLE_POP \ + __pragma(warning(pop)) + #else + #define Q_NOWARN_DEPRECATED_PUSH #define Q_NOWARN_DEPRECATED_POP +#define Q_NOWARN_UNREACHABLE_PUSH +#define Q_NOWARN_UNREACHABLE_POP + #endif #endif diff --git a/src/core/qgsstacktrace.cpp b/src/core/qgsstacktrace.cpp index a0bafc8315c..081d5fc90fb 100644 --- a/src/core/qgsstacktrace.cpp +++ b/src/core/qgsstacktrace.cpp @@ -49,7 +49,7 @@ QVector QgsStackTrace::trace( _EXCEPTION_POINTERS *Exc paths = QgsStackTrace::mSymbolPaths.toStdString().c_str(); } - BOOL success = SymInitialize( process, paths, TRUE ); + SymInitialize( process, paths, TRUE ); // StackWalk64() may modify context record passed to it, so we will // use a copy. diff --git a/src/core/qgsunittypes.cpp b/src/core/qgsunittypes.cpp index 0ff6c67ddaa..156c95d66df 100644 --- a/src/core/qgsunittypes.cpp +++ b/src/core/qgsunittypes.cpp @@ -1485,6 +1485,8 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::AreaUnit unit, int decimals, bool keepBaseUnit ) { AreaValue result; + result.value = -1.0; + result.unit = AreaUnknownUnit; // If we are not forced to keep the base units, switch to meter calculation if ( unit == AreaSquareMillimeters ) diff --git a/src/core/qgsvectorlayerutils.cpp b/src/core/qgsvectorlayerutils.cpp index b37a921730b..05b5d30b183 100644 --- a/src/core/qgsvectorlayerutils.cpp +++ b/src/core/qgsvectorlayerutils.cpp @@ -127,7 +127,7 @@ QVariant QgsVectorLayerUtils::createUniqueValue( const QgsVectorLayer *layer, in default: // todo other types - dates? times? - return QVariant(); + break; } } diff --git a/src/core/qgsziputils.cpp b/src/core/qgsziputils.cpp index b43222673f9..3f4803cabdb 100644 --- a/src/core/qgsziputils.cpp +++ b/src/core/qgsziputils.cpp @@ -139,8 +139,8 @@ bool QgsZipUtils::zip( const QString &zipFilename, const QStringList &files ) { QString err = QObject::tr( "Error input file does not exist: '%1'" ).arg( file ); QgsMessageLog::logMessage( err, QStringLiteral( "QgsZipUtils" ) ); - return false; zip_close( z ); + return false; } zip_source *src = zip_source_file( z, file.toStdString().c_str(), 0, 0 ); diff --git a/src/gui/layout/qgslayoutruler.cpp b/src/gui/layout/qgslayoutruler.cpp index 931dc8a5ed0..b73c78dde40 100644 --- a/src/gui/layout/qgslayoutruler.cpp +++ b/src/gui/layout/qgslayoutruler.cpp @@ -419,7 +419,7 @@ void QgsLayoutRuler::drawSmallDivisions( QPainter *painter, double startPos, int double smallMarkerPos = startPos; double smallDivisionSpacing = rulerScale / numDivisions; - double pixelCoord; + double pixelCoord = 0.0; //draw numDivisions small divisions for ( int i = 0; i < numDivisions; ++i ) diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index a18edb0ab7b..8be12cb54aa 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -1,6 +1,6 @@ /*************************************************************************** qgisinterface.h - Interface class for exposing functions in QgisApp for use by plugins + Interface class for exposing functions in QgisApp for use by plugins ------------------- begin : 2004-02-11 copyright : (C) 2004 by Gary E.Sherman @@ -69,6 +69,7 @@ class QgsStatusBar; * could provide their own implementation to be able to use plugins. */ +Q_NOWARN_DEPRECATED_PUSH class GUI_EXPORT QgisInterface : public QObject { Q_OBJECT @@ -459,7 +460,6 @@ class GUI_EXPORT QgisInterface : public QObject #endif virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED; - /** Accessors for inserting items into menus and toolbars. * An item can be inserted before any existing action. */ @@ -797,5 +797,6 @@ class GUI_EXPORT QgisInterface : public QObject */ void layerSavedAs( QgsMapLayer *l, const QString &path ); }; +Q_NOWARN_DEPRECATED_POP #endif //#ifndef QGISINTERFACE_H diff --git a/src/gui/qgsfontbutton.cpp b/src/gui/qgsfontbutton.cpp index 19c68948352..06d6202805e 100644 --- a/src/gui/qgsfontbutton.cpp +++ b/src/gui/qgsfontbutton.cpp @@ -173,7 +173,7 @@ bool QgsFontButton::event( QEvent *e ) { QHelpEvent *helpEvent = static_cast< QHelpEvent *>( e ); QString toolTip; - double fontSize; + double fontSize = 0.0; switch ( mMode ) { case ModeTextRenderer: diff --git a/src/gui/raster/qgspalettedrendererwidget.cpp b/src/gui/raster/qgspalettedrendererwidget.cpp index bf2a695d357..9121619c6fb 100644 --- a/src/gui/raster/qgspalettedrendererwidget.cpp +++ b/src/gui/raster/qgspalettedrendererwidget.cpp @@ -583,7 +583,7 @@ QVariant QgsPalettedRendererModel::data( const QModelIndex &index, int role ) co } default: - return QVariant(); + break; } return QVariant(); diff --git a/src/plugins/georeferencer/qgsimagewarper.cpp b/src/plugins/georeferencer/qgsimagewarper.cpp index 7914932e1a9..0f8459f90f1 100644 --- a/src/plugins/georeferencer/qgsimagewarper.cpp +++ b/src/plugins/georeferencer/qgsimagewarper.cpp @@ -361,7 +361,7 @@ GDALResampleAlg QgsImageWarper::toGDALResampleAlg( const QgsImageWarper::Resampl case Lanczos: return GRA_Lanczos; default: - return GRA_NearestNeighbour; + break; }; //avoid warning diff --git a/src/providers/grass/qgis.v.in.cpp b/src/providers/grass/qgis.v.in.cpp index 18976874968..dc663749f91 100644 --- a/src/providers/grass/qgis.v.in.cpp +++ b/src/providers/grass/qgis.v.in.cpp @@ -43,23 +43,23 @@ extern "C" #include "qgsgrass.h" #include "qgsgrassdatafile.h" -static struct line_pnts *line = Vect_new_line_struct(); +static struct line_pnts *gLine = Vect_new_line_struct(); void writePoint( struct Map_info *map, int type, const QgsPointXY &point, struct line_cats *cats ) { - Vect_reset_line( line ); - Vect_append_point( line, point.x(), point.y(), 0 ); - Vect_write_line( map, type, line, cats ); + Vect_reset_line( gLine ); + Vect_append_point( gLine, point.x(), point.y(), 0 ); + Vect_write_line( map, type, gLine, cats ); } void writePolyline( struct Map_info *map, int type, const QgsPolyline &polyline, struct line_cats *cats ) { - Vect_reset_line( line ); + Vect_reset_line( gLine ); Q_FOREACH ( const QgsPointXY &point, polyline ) { - Vect_append_point( line, point.x(), point.y(), 0 ); + Vect_append_point( gLine, point.x(), point.y(), 0 ); } - Vect_write_line( map, type, line, cats ); + Vect_write_line( map, type, gLine, cats ); } static struct Map_info *finalMap = 0; diff --git a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp index b128847e027..a5ae1a379aa 100644 --- a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp +++ b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp @@ -45,6 +45,16 @@ #define QT_NO_DEBUG_OUTPUT #endif +#if __cplusplus >= 201500 +#define FALLTHROUGH [[fallthrough]]; +#elif defined(__clang__) +#define FALLTHROUGH //[[clang::fallthrough]] +#elif defined(__GNUC__) && __GNUC__ >= 7 +#define FALLTHROUGH [[gnu::fallthrough]]; +#else +#define FALLTHROUGH +#endif + #include "qsql_ocispatial.h" #include "wkbptr.h" @@ -699,7 +709,10 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError setCharset( *hbnd, OCI_HTYPE_BIND ); break; } - } // fall through for OUT values + + FALLTHROUGH + } + default: { const QString s = val.toString(); @@ -2006,6 +2019,9 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector columns[i].lengths[row] = 0; break; } + + FALLTHROUGH + case QVariant::ByteArray: default: { diff --git a/src/providers/postgres/qgspostgresexpressioncompiler.cpp b/src/providers/postgres/qgspostgresexpressioncompiler.cpp index aa44dfd2b9a..41427aa6bc7 100644 --- a/src/providers/postgres/qgspostgresexpressioncompiler.cpp +++ b/src/providers/postgres/qgspostgresexpressioncompiler.cpp @@ -195,8 +195,8 @@ QgsSqlExpressionCompiler::Result QgsPostgresExpressionCompiler::compileNode( con } default: - return QgsSqlExpressionCompiler::compileNode( node, result ); + break; } - return Fail; + return QgsSqlExpressionCompiler::compileNode( node, result ); } diff --git a/src/server/qgsconfigcache.h b/src/server/qgsconfigcache.h index d5e599116e4..b2fafa2d011 100644 --- a/src/server/qgsconfigcache.h +++ b/src/server/qgsconfigcache.h @@ -29,10 +29,10 @@ #include "qgis_server.h" #include "qgis_sip.h" #include "qgswmsconfigparser.h" +#include "qgsproject.h" class QgsServerProjectParser; class QgsAccessControl; -class QgsProject; class SERVER_EXPORT QgsConfigCache : public QObject { diff --git a/tests/src/gui/CMakeLists.txt b/tests/src/gui/CMakeLists.txt index 4552039787e..d93d898b845 100644 --- a/tests/src/gui/CMakeLists.txt +++ b/tests/src/gui/CMakeLists.txt @@ -75,13 +75,13 @@ INCLUDE_DIRECTORIES(SYSTEM #ENDIF (APPLE) SET(IMAGE_RCCS ../../../images/images.qrc) -QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS}) MACRO (ADD_QGIS_TEST testname testsrc) SET(qgis_${testname}_SRCS ${testsrc} ${util_SRCS}) SET(qgis_${testname}_MOC_CPPS ${testsrc}) - ADD_EXECUTABLE(qgis_${testname} ${qgis_${testname}_SRCS} ${IMAGE_RCC_SRCS}) + ADD_EXECUTABLE(qgis_${testname} ${qgis_${testname}_SRCS} ${IMAGE_RCCS}) SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES AUTOMOC TRUE) + SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES AUTORCC TRUE) TARGET_LINK_LIBRARIES(qgis_${testname} ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY}