[PATCH] D56397: [OpenMP] Silence warning about fallthrough

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 4 07:59:34 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL353052: [OMPT] Make sure that OMPT is enabled when accessing internals of the runtime (authored by jprotze, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56397?vs=181988&id=185056#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56397/new/

https://reviews.llvm.org/D56397

Files:
  openmp/trunk/runtime/src/kmp_dispatch.cpp
  openmp/trunk/runtime/src/kmp_os.h
  openmp/trunk/runtime/src/kmp_runtime.cpp
  openmp/trunk/runtime/src/kmp_tasking.cpp


Index: openmp/trunk/runtime/src/kmp_runtime.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_runtime.cpp
+++ openmp/trunk/runtime/src/kmp_runtime.cpp
@@ -6421,6 +6421,7 @@
         // library. Assume the other library is alive.
         // WARN( ... ); // TODO: Issue a warning.
         file_name = "unknown library";
+        KMP_FALLTHROUGH();
       // Attention! Falling to the next case. That's intentional.
       case 1: { // Neighbor is alive.
         // Check it is allowed.
Index: openmp/trunk/runtime/src/kmp_dispatch.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_dispatch.cpp
+++ openmp/trunk/runtime/src/kmp_dispatch.cpp
@@ -348,6 +348,7 @@
       /* too few iterations: fall-through to kmp_sch_static_balanced */
     } // if
     /* FALL-THROUGH to static balanced */
+    KMP_FALLTHROUGH();
   } // case
 #endif
   case kmp_sch_static_balanced: {
Index: openmp/trunk/runtime/src/kmp_os.h
===================================================================
--- openmp/trunk/runtime/src/kmp_os.h
+++ openmp/trunk/runtime/src/kmp_os.h
@@ -296,6 +296,20 @@
 
 #define KMP_CACHE_PREFETCH(ADDR) /* nothing */
 
+// Define attribute that indicates that the fall through from the previous 
+// case label is intentional and should not be diagnosed by a compiler
+//   Code 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 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__))
+#else
+#  define KMP_FALLTHROUGH() ((void)0)
+#endif
+
 // Define attribute that indicates a function does not return
 #if __cplusplus >= 201103L
 #define KMP_NORETURN [[noreturn]]
Index: openmp/trunk/runtime/src/kmp_tasking.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_tasking.cpp
+++ openmp/trunk/runtime/src/kmp_tasking.cpp
@@ -4205,6 +4205,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;
+    KMP_FALLTHROUGH();
   case 2: // num_tasks provided
     if (grainsize > tc) {
       num_tasks = tc; // too big num_tasks requested, adjust values


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56397.185056.patch
Type: text/x-patch
Size: 2562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190204/a19ecaad/attachment.bin>


More information about the llvm-commits mailing list