Skip to content

Start using fallthrough annotations instead of comments

clang doesn't handle fallthrough comments, so it generates the following warning:

[1100/1333] Compiling C object src/gallium/auxiliary/libgallium.a.p/gallivm_lp_bld_sample_soa.c.o
../src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c:2176:10: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
         case PIPE_TEX_MIPFILTER_LINEAR:
         ^
../src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c:2176:10: note: insert '__attribute__((fallthrough));' to silence this warning
         case PIPE_TEX_MIPFILTER_LINEAR:
         ^
         __attribute__((fallthrough)); 
../src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c:2176:10: note: insert 'break;' to avoid fall-through
         case PIPE_TEX_MIPFILTER_LINEAR:
         ^
         break; 
1 warning generated.

GCC supports __attribute__((fallthrough)); so this MR is a first update to switch to attribute.

I'm not sure if other compilers support this attribute; maybe CI can answer this question. The alternative is to add something like:

#if ...
#define FALLTHROUGH __attribute__((fallthrough));
#else
#define FALLTHROUGH /* fallthrough */
#endif

edit: FALLTHROUGH macro added in !7747 (a09fe11c)

Edited by Pierre-Eric Pelloux-Prayer

Merge request reports