Skip to content
Permalink
Browse files
Flip DEFAULT_BUILTIN_UNREACHABLE to BUILTIN_UNREACHABLE and move
out of default: blocks

Otherwise we lose the benefit of warnings emitted when a switch
is missing handling of newly added enum valus
  • Loading branch information
nyalldawson committed Nov 4, 2021
1 parent eab0801 commit 6f45adf199c5967294ade3b7c4d30bbd7c1c991d
Showing with 10 additions and 29 deletions.
  1. +3 −5 src/core/qgis.h
  2. +7 −24 src/gui/qgsfilecontentsourcelineedit.cpp
@@ -1998,8 +1998,7 @@ typedef unsigned long long qgssize;

#ifndef SIP_RUN
#ifdef _MSC_VER
#define DEFAULT_BUILTIN_UNREACHABLE \
default: \
#define BUILTIN_UNREACHABLE \
__assume(false);
#elif defined(__GNUC__) && !defined(__clang__)
// Workaround a GCC bug where a -Wreturn-type warning is emitted in constructs
@@ -2012,11 +2011,10 @@ typedef unsigned long long qgssize;
// return "foo";
// }
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87951
#define DEFAULT_BUILTIN_UNREACHABLE \
default: \
#define BUILTIN_UNREACHABLE \
__builtin_unreachable();
#else
#define DEFAULT_BUILTIN_UNREACHABLE
#define BUILTIN_UNREACHABLE
#endif
#endif // SIP_RUN

@@ -306,8 +306,8 @@ QString QgsPictureSourceLineEditBase::fileFilter() const
}
return QString( "%1 (%2);;%3 (*.*)" ).arg( tr( "Images" ), formatsFilter.join( QLatin1Char( ' ' ) ), tr( "All files" ) );
}
DEFAULT_BUILTIN_UNREACHABLE
}
BUILTIN_UNREACHABLE
}

QString QgsPictureSourceLineEditBase::selectFileTitle() const
@@ -317,12 +317,9 @@ QString QgsPictureSourceLineEditBase::selectFileTitle() const
case Svg:
return tr( "Select SVG File" );
case Image:
{
return tr( "Select Image File" );
}

DEFAULT_BUILTIN_UNREACHABLE
}
BUILTIN_UNREACHABLE
}

QString QgsPictureSourceLineEditBase::fileFromUrlTitle() const
@@ -332,12 +329,9 @@ QString QgsPictureSourceLineEditBase::fileFromUrlTitle() const
case Svg:
return tr( "SVG From URL" );
case Image:
{
return tr( "Image From URL" );
}

DEFAULT_BUILTIN_UNREACHABLE
}
BUILTIN_UNREACHABLE
}

QString QgsPictureSourceLineEditBase::fileFromUrlText() const
@@ -347,12 +341,9 @@ QString QgsPictureSourceLineEditBase::fileFromUrlText() const
case Svg:
return tr( "Enter SVG URL" );
case Image:
{
return tr( "Enter image URL" );
}

DEFAULT_BUILTIN_UNREACHABLE
}
BUILTIN_UNREACHABLE
}

QString QgsPictureSourceLineEditBase::embedFileTitle() const
@@ -362,12 +353,9 @@ QString QgsPictureSourceLineEditBase::embedFileTitle() const
case Svg:
return tr( "Embed SVG File" );
case Image:
{
return tr( "Embed Image File" );
}

DEFAULT_BUILTIN_UNREACHABLE
}
BUILTIN_UNREACHABLE
}

QString QgsPictureSourceLineEditBase::extractFileTitle() const
@@ -377,12 +365,9 @@ QString QgsPictureSourceLineEditBase::extractFileTitle() const
case Svg:
return tr( "Extract SVG File" );
case Image:
{
return tr( "Extract Image File" );
}

DEFAULT_BUILTIN_UNREACHABLE
}
BUILTIN_UNREACHABLE
}

QString QgsPictureSourceLineEditBase::defaultSettingsKey() const
@@ -392,11 +377,9 @@ QString QgsPictureSourceLineEditBase::defaultSettingsKey() const
case Svg:
return QStringLiteral( "/UI/lastSVGDir" );
case Image:
{
return QStringLiteral( "/UI/lastImageDir" );
}
DEFAULT_BUILTIN_UNREACHABLE
}
BUILTIN_UNREACHABLE
}

///@endcond

0 comments on commit 6f45adf

Please sign in to comment.