[Openmp-commits] [PATCH] D56397: [OpenMP] Silence warning about fallthrough
Joachim Protze via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jan 7 09:30:37 PST 2019
protze.joachim created this revision.
protze.joachim added reviewers: jlpeyton, AndreyChurbanov, Hahnfeld.
Herald added subscribers: openmp-commits, guansong.
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.
Repository:
rOMP OpenMP
https://reviews.llvm.org/D56397
Files:
runtime/src/kmp.h
runtime/src/kmp_dispatch.cpp
runtime/src/kmp_runtime.cpp
runtime/src/kmp_tasking.cpp
Index: runtime/src/kmp_tasking.cpp
===================================================================
--- runtime/src/kmp_tasking.cpp
+++ runtime/src/kmp_tasking.cpp
@@ -4204,6 +4204,7 @@
case 0: // no schedule clause specified, we can choose the default
// let's try to schedule (team_size*10) tasks
grainsize = thread->th.th_team_nproc * 10;
+ _LIBOMP_FALLTHROUGH();
case 2: // num_tasks provided
if (grainsize > tc) {
num_tasks = tc; // too big num_tasks requested, adjust values
Index: runtime/src/kmp_runtime.cpp
===================================================================
--- runtime/src/kmp_runtime.cpp
+++ runtime/src/kmp_runtime.cpp
@@ -6343,6 +6343,7 @@
// library. Assume the other library is alive.
// WARN( ... ); // TODO: Issue a warning.
file_name = "unknown library";
+ _LIBOMP_FALLTHROUGH();
// Attention! Falling to the next case. That's intentional.
case 1: { // Neighbor is alive.
// Check it is allowed.
Index: runtime/src/kmp_dispatch.cpp
===================================================================
--- runtime/src/kmp_dispatch.cpp
+++ runtime/src/kmp_dispatch.cpp
@@ -349,6 +349,7 @@
/* too few iterations: fall-through to kmp_sch_static_balanced */
} // if
/* FALL-THROUGH to static balanced */
+ _LIBOMP_FALLTHROUGH();
} // case
#endif
case kmp_sch_static_balanced: {
Index: runtime/src/kmp.h
===================================================================
--- runtime/src/kmp.h
+++ runtime/src/kmp.h
@@ -3970,6 +3970,18 @@
extern int __kmpc_get_target_offload();
#endif
+// from libcxx/include/__config
+// Use a function like macro to imply that it must be followed by a semicolon
+#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
+# define _LIBOMP_FALLTHROUGH() [[fallthrough]]
+#elif __has_cpp_attribute(clang::fallthrough)
+# define _LIBOMP_FALLTHROUGH() [[clang::fallthrough]]
+#elif __has_attribute(fallthough) || _GNUC_VER >= 700
+# define _LIBOMP_FALLTHROUGH() __attribute__((__fallthrough__))
+#else
+# define _LIBOMP_FALLTHROUGH() ((void)0)
+#endif
+
#ifdef __cplusplus
}
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56397.180512.patch
Type: text/x-patch
Size: 2175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190107/a83adfee/attachment.bin>
More information about the Openmp-commits
mailing list