Page MenuHomePhabricator

[OpenMP] Silence warning about fallthrough

Authored by protze.joachim on Jan 7 2019, 9:30 AM.



The three switch fallthrough generate a warning with -Wimplicit-fallthrough.
Two are documented as fallthrough, one is not, but I think the intention is to also fallthrough in kmp_tasking.cpp.

Not sure whether kmp.h is the best place to define the macro.

Diff Detail

Event Timeline

protze.joachim created this revision.Jan 7 2019, 9:30 AM
jlpeyton added inline comments.Jan 15 2019, 11:49 AM
3973–3984 ↗(On Diff #180512)

Move this to kmp_os.h around the noreturn attribute definition which looks very similar to this one, and rename it KMP_FALLTHROUGH.

Updated as requested

This revision is now accepted and ready to land.Jan 16 2019, 8:56 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2019, 7:59 AM
david2050 added a subscriber: david2050.EditedFeb 6 2019, 12:23 PM

This change breaks builds fort compilers because the "&&" in the preprocessor does not protect the case that __has_cpp_attribute is not defined. Better something like

#if __cplusplus > 201402L  
#if __has_cpp_attribute(fallthrough)
#  define KMP_FALLTHROUGH() [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)  
#  define KMP_FALLTHROUGH() [[clang::fallthrough]]
#elif __has_attribute(fallthough) || _GNUC_VER >= 700
#  define KMP_FALLTHROUGH() __attribute__((__fallthrough__))
#if !defined(KMP_FALLTHROUGH)
#  define KMP_FALLTHROUGH() ((void)0)
This comment was removed by david2050.