https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79750
Bug ID: 79750 Summary: -Wimplicit-fallthrough= comment detection gets confused by #if Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sgunderson at bigfoot dot com Target Milestone: --- Hi, It seems that fallthrough comments are not properly parsed if they are followed by a preprocessor statement. Minified test case: atum17:~> /usr/lib/gcc-snapshot/bin/g++ -v Using built-in specs. COLLECT_GCC=/usr/lib/gcc-snapshot/bin/g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 20170226-1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,ada,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr/lib/gcc-snapshot --with-gcc-major-version-only --program-prefix= --enable-shared --enable-linker-build-id --disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.0.1 20170226 (experimental) [trunk revision 245744] (Debian 20170226-1) atum17:~> cat test.cc int func(int x) { switch (x) { case 0: x = 1; //-fallthrough #if 1 case 1: #endif case 2: ++x; } return x; } atum17:~> /usr/lib/gcc-snapshot/bin/g++ -Wall -Wextra -c test.cc test.cc: In function 'int func(int)': test.cc:5:5: warning: this statement may fall through [-Wimplicit-fallthrough=] x = 1; ~~^~~ test.cc:8:2: note: here case 1: ^~~~ If I remove the #if 1, there is no warning.