diff mbox

Implement -Wswitch-fallthrough: libstdc++

Message ID 20160711195759.GZ13963@redhat.com
State New
Headers show

Commit Message

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

	PR c/7652
	* libsupc++/hash_bytes.cc: Use __builtin_fallthrough.

Comments

Jonathan Wakely July 11, 2016, 10:18 p.m. UTC | #1
On 11 July 2016 at 20:57, Marek Polacek wrote:
>
> 2016-07-11  Marek Polacek  <polacek@redhat.com>
>
>         PR c/7652
>         * libsupc++/hash_bytes.cc: Use __builtin_fallthrough.
>
> diff --git gcc/libstdc++-v3/libsupc++/hash_bytes.cc gcc/libstdc++-v3/libsupc++/hash_bytes.cc
> index 2e5bbfa..818331f 100644
> --- gcc/libstdc++-v3/libsupc++/hash_bytes.cc
> +++ gcc/libstdc++-v3/libsupc++/hash_bytes.cc
> @@ -95,8 +95,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>        {
>        case 3:
>         hash ^= static_cast<unsigned char>(buf[2]) << 16;
> +       __builtin_fallthrough ();
>        case 2:
>         hash ^= static_cast<unsigned char>(buf[1]) << 8;
> +       __builtin_fallthrough ();
>        case 1:
>         hash ^= static_cast<unsigned char>(buf[0]);
>         hash *= m;

Nice to see this feature implemented!

The libstdc++ change is gladly approved with much rejoicing. Thanks.
diff mbox

Patch

diff --git gcc/libstdc++-v3/libsupc++/hash_bytes.cc gcc/libstdc++-v3/libsupc++/hash_bytes.cc
index 2e5bbfa..818331f 100644
--- gcc/libstdc++-v3/libsupc++/hash_bytes.cc
+++ gcc/libstdc++-v3/libsupc++/hash_bytes.cc
@@ -95,8 +95,10 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
       case 3:
 	hash ^= static_cast<unsigned char>(buf[2]) << 16;
+	__builtin_fallthrough ();
       case 2:
 	hash ^= static_cast<unsigned char>(buf[1]) << 8;
+	__builtin_fallthrough ();
       case 1:
 	hash ^= static_cast<unsigned char>(buf[0]);
 	hash *= m;