Skip to content

Commit

Permalink
Flip DEFAULT_BUILTIN_UNREACHABLE to BUILTIN_UNREACHABLE and move
Browse files Browse the repository at this point in the history
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 9, 2021
1 parent 5171194 commit 21d9b92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
8 changes: 3 additions & 5 deletions src/core/qgis.h
Expand Up @@ -1810,8 +1810,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
Expand All @@ -1824,11 +1823,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

Expand Down
31 changes: 7 additions & 24 deletions src/gui/qgsfilecontentsourcelineedit.cpp
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 21d9b92

Please sign in to comment.