This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Implement -Wswitch-fallthrough: libatomic
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 11 Jul 2016 21:55:02 +0200
- Subject: Re: Implement -Wswitch-fallthrough: libatomic
- Authentication-results: sourceware.org; auth=none
- References: <20160711194340.GI13963@redhat.com>
2016-07-11 Marek Polacek <polacek@redhat.com>
PR c/7652
* libatomic_i.h (libat_fallthrough): New macro.
* gcas.c (libat_compare_exchange): Use libat_fallthrough.
* gexch.c (libat_exchange): Likewise.
* glfree.c (libat_is_lock_free): Likewise.
* gload.c (libat_load): Likewise.
* gstore.c (libat_store): Likewise.
diff --git gcc/libatomic/gcas.c gcc/libatomic/gcas.c
index 6a5025d..224df8e 100644
--- gcc/libatomic/gcas.c
+++ gcc/libatomic/gcas.c
@@ -92,8 +92,8 @@ libat_compare_exchange (size_t n, void *mptr, void *eptr, void *dptr,
case 8: EXACT(8); goto L16;
case 16: EXACT(16); break;
- case 3: L4: LARGER(4); /* FALLTHRU */
- case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
+ case 3: L4: LARGER(4); /* FALLTHRU */ libat_fallthrough ();
+ case 5 ... 7: L8: LARGER(8); /* FALLTHRU */ libat_fallthrough ();
case 9 ... 15: L16: LARGER(16); break;
Lsucc:
diff --git gcc/libatomic/gexch.c gcc/libatomic/gexch.c
index fddb794..876ae87 100644
--- gcc/libatomic/gexch.c
+++ gcc/libatomic/gexch.c
@@ -116,8 +116,8 @@ libat_exchange (size_t n, void *mptr, void *vptr, void *rptr, int smodel)
case 8: EXACT(8); goto L16;
case 16: EXACT(16); break;
- case 3: L4: LARGER(4); /* FALLTHRU */
- case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
+ case 3: L4: LARGER(4); /* FALLTHRU */ libat_fallthrough ();
+ case 5 ... 7: L8: LARGER(8); /* FALLTHRU */ libat_fallthrough ();
case 9 ... 15: L16: LARGER(16); break;
Lfinish:
diff --git gcc/libatomic/glfree.c gcc/libatomic/glfree.c
index fd1b3a7..3bb09de 100644
--- gcc/libatomic/glfree.c
+++ gcc/libatomic/glfree.c
@@ -56,8 +56,8 @@ libat_is_lock_free (size_t n, void *ptr)
case 8: EXACT(8); goto L16;
case 16: EXACT(16); break;
- case 3: L4: LARGER(4); /* FALLTHRU */
- case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
+ case 3: L4: LARGER(4); /* FALLTHRU */ libat_fallthrough ();
+ case 5 ... 7: L8: LARGER(8); /* FALLTHRU */ libat_fallthrough ();
case 9 ... 15: L16: LARGER(16); break;
}
diff --git gcc/libatomic/gload.c gcc/libatomic/gload.c
index 64a0dc5..b4cc61c 100644
--- gcc/libatomic/gload.c
+++ gcc/libatomic/gload.c
@@ -79,8 +79,8 @@ libat_load (size_t n, void *mptr, void *rptr, int smodel)
case 8: EXACT(8); goto L16;
case 16: EXACT(16); break;
- case 3: L4: LARGER(4); /* FALLTHRU */
- case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
+ case 3: L4: LARGER(4); /* FALLTHRU */ libat_fallthrough ();
+ case 5 ... 7: L8: LARGER(8); /* FALLTHRU */ libat_fallthrough ();
case 9 ... 15: L16: LARGER(16); break;
Lfinish:
diff --git gcc/libatomic/gstore.c gcc/libatomic/gstore.c
index af1d060..90a7430 100644
--- gcc/libatomic/gstore.c
+++ gcc/libatomic/gstore.c
@@ -91,8 +91,8 @@ libat_store (size_t n, void *mptr, void *vptr, int smodel)
case 8: EXACT(8); goto L16;
case 16: EXACT(16); break;
- case 3: L4: LARGER(4); /* FALLTHRU */
- case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
+ case 3: L4: LARGER(4); /* FALLTHRU */ libat_fallthrough ();
+ case 5 ... 7: L8: LARGER(8); /* FALLTHRU */ libat_fallthrough ();
case 9 ... 15: L16: LARGER(16); break;
}
diff --git gcc/libatomic/libatomic_i.h gcc/libatomic/libatomic_i.h
index 9206a8e..0faa103 100644
--- gcc/libatomic/libatomic_i.h
+++ gcc/libatomic/libatomic_i.h
@@ -200,6 +200,12 @@ void libat_unlock_n (void *ptr, size_t n);
# define DECLARE_1(RET,NAME,ARGS) RET C2(libat_,NAME) ARGS MAN(NAME)
#endif
+#if __GNUC__ >= 7
+# define libat_fallthrough() __builtin_fallthrough ()
+#else
+# define libat_fallthrough()
+#endif
+
/* Prefix to use when calling internal, possibly ifunc'ed functions. */
#if HAVE_IFUNC
# define local_ ifunc_