diff mbox

Implement -Wswitch-fallthrough: libgomp

Message ID 20160711195631.GW13963@redhat.com
State New
Headers show

Commit Message

Marek Polacek July 11, 2016, 7:56 p.m. UTC
2016-07-11  Marek Polacek  <polacek@redhat.com>

	PR c/7652
	* libgomp.h (gomp_fallthrough): Define.
	* oacc-init.c (resolve_device): Use gomp_fallthrough.
	* testsuite/libgomp.c++/cancel-parallel-2.C: Add __builtin_fallthrough.
	* testsuite/libgomp.c/cancel-parallel-2.c: Add __builtin_fallthrough.
diff mbox

Patch

diff --git gcc/libgomp/libgomp.h gcc/libgomp/libgomp.h
index 7b2671b..c0c5e60 100644
--- gcc/libgomp/libgomp.h
+++ gcc/libgomp/libgomp.h
@@ -1080,6 +1080,12 @@  extern int gomp_test_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
 # define ialias_call(fn) fn
 #endif
 
+#if __GNUC__ >= 7
+# define gomp_fallthrough() __builtin_fallthrough ()
+#else
+# define gomp_fallthrough()
+#endif
+
 /* Helper function for priority_node_to_task() and
    task_to_priority_node().
 
diff --git gcc/libgomp/oacc-init.c gcc/libgomp/oacc-init.c
index f2325ad..70308fc 100644
--- gcc/libgomp/oacc-init.c
+++ gcc/libgomp/oacc-init.c
@@ -144,6 +144,7 @@  resolve_device (acc_device_t d, bool fail_is_error)
 	d = acc_device_not_host;
       }
       /* FALLTHROUGH */
+      gomp_fallthrough ();
 
     case acc_device_not_host:
       /* Find the first available device after acc_device_not_host.  */
diff --git gcc/libgomp/testsuite/libgomp.c++/cancel-parallel-2.C gcc/libgomp/testsuite/libgomp.c++/cancel-parallel-2.C
index 23b8caa..f793f8a 100644
--- gcc/libgomp/testsuite/libgomp.c++/cancel-parallel-2.C
+++ gcc/libgomp/testsuite/libgomp.c++/cancel-parallel-2.C
@@ -31,6 +31,7 @@  foo (int *x)
       case 2:
 	usleep (1000);
 	/* FALLTHRU */
+	__builtin_fallthrough ();
       case 1:;
 	#pragma omp cancellation point parallel
 	break;
diff --git gcc/libgomp/testsuite/libgomp.c/cancel-parallel-2.c gcc/libgomp/testsuite/libgomp.c/cancel-parallel-2.c
index 20adb55..054a96e 100644
--- gcc/libgomp/testsuite/libgomp.c/cancel-parallel-2.c
+++ gcc/libgomp/testsuite/libgomp.c/cancel-parallel-2.c
@@ -27,6 +27,7 @@  foo (int *x)
       case 2:
 	usleep (1000);
 	/* FALLTHRU */
+	__builtin_fallthrough ();
       case 1:;
 	#pragma omp cancellation point parallel
 	break;