This is an archive of the discontinued LLVM Phabricator instance.

sanitizer: support GCC's fallthrough attribute
ClosedPublic

Authored by marxin on May 3 2022, 1:55 AM.

Details

Summary

Fixes:
sanitizer_stack_store.cpp:257:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

when being built with GCC.

Diff Detail

Event Timeline

marxin created this revision.May 3 2022, 1:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2022, 1:55 AM
marxin requested review of this revision.May 3 2022, 1:55 AM
dvyukov accepted this revision.May 3 2022, 2:14 AM
This revision is now accepted and ready to land.May 3 2022, 2:14 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2022, 2:31 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
marxin added a comment.May 3 2022, 4:40 AM

It caused:

/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp:258:7: error: use of the 'fallthrough' attribute is a C++17 extension [-Werror,-Wc++17-attribute-extensions]
      FALLTHROUGH;
      ^
b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/sanitizer_common../sanitizer_common/sanitizer_internal_defs.h:263:25: note: expanded from macro 'FALLTHROUGH'
#  define FALLTHROUGH [[fallthrough]]

Which is similar to:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105377

The warning is misleading as it's guarded in __has_cpp_attribute.

If this is a new warning, maybe reordering these will help:

#if has_cpp_attribute(fallthrough)
#elif
has_cpp_attribute(clang::fallthrough)

marxin added a comment.May 3 2022, 4:54 AM

Yep, that works. Let me push such change.