Guard FALLTHROUGH annotations after assert()

clang warns if it can determine that the assert() never returns and
there's a fall-through annotation below.

Acked-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10220>
This commit is contained in:
Michel Dänzer 2021-04-13 17:40:15 +02:00 committed by Marge Bot
parent 2928c21eb7
commit 9ef5372441
5 changed files with 12 additions and 2 deletions

View File

@ -2208,8 +2208,10 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
*/
switch (mip_filter) {
default:
assert(0 && "bad mip_filter value in lp_build_sample_soa()");
debug_assert(0 && "bad mip_filter value in lp_build_sample_soa()");
#if defined(NDEBUG) || defined(DEBUG)
FALLTHROUGH;
#endif
case PIPE_TEX_MIPFILTER_NONE:
/* always use mip level 0 */
first_level = bld->dynamic_state->first_level(bld->dynamic_state,

View File

@ -408,7 +408,9 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
switch (swizzles[i]) {
default:
assert(0);
#if defined(NDEBUG) || defined(DEBUG)
FALLTHROUGH;
#endif
case PIPE_SWIZZLE_X:
case PIPE_SWIZZLE_Y:
case PIPE_SWIZZLE_Z:

View File

@ -426,7 +426,9 @@ fd_msaa_samples(unsigned samples)
switch (samples) {
default:
debug_assert(0);
#if defined(NDEBUG) || defined(DEBUG)
FALLTHROUGH;
#endif
case 0:
case 1:
return MSAA_ONE;

View File

@ -144,8 +144,10 @@ FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format)
#endif
default:
/* NOTE: Can't be "unreachable", as it's quite reachable. */
assert(!"unexpected VdpYCbCrFormat");
debug_assert(!"unexpected VdpYCbCrFormat");
#if defined(NDEBUG) || defined(DEBUG)
FALLTHROUGH;
#endif
#ifdef VDP_YCBCR_FORMAT_Y_UV_444
case VDP_YCBCR_FORMAT_Y_UV_444:
#endif

View File

@ -184,7 +184,9 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture,
break;
default:
assert(0 && "Unexpected texture in st_gl_texture_dims_to_pipe_dims()");
#if defined(NDEBUG) || defined(DEBUG)
FALLTHROUGH;
#endif
case GL_TEXTURE_3D:
case GL_PROXY_TEXTURE_3D:
*widthOut = widthIn;