arch, arm: Fix implicit-fallthrough GCC warnings
authorChun-Chen Hsu <chunchenhsu@google.com>
Tue, 13 Mar 2018 09:44:52 +0000 (17:44 +0800)
committerChun-Chen TK Hsu <chunchenhsu@google.com>
Tue, 20 Mar 2018 20:17:00 +0000 (20:17 +0000)
GCC 7 generates spurious fallthrough warnings in nested switch blocks
where the inner switch block return.  There is already a GCC fix [1]
submitted for review but, until it is merged into GCC trunk, GEM5 will
not build with GCC 7 due to these fallthrough warnings.  This patch
silences the spurious fallthrough warnings by appending a M5_UNREACHABLE
statement in the outer switch cases.

Note there is another GEM5 patch [2] to fix other fallthrough warnings.

[1] https://gcc.gnu.org/ml/gcc-patches/2018-02/msg01105.html
[2] https://gem5-review.googlesource.com/c/public/gem5/+/8541

Change-Id: I97cd8bfa90a88e93cee60cf27a8c93611d11a242
Signed-off-by: Chun-Chen Hsu <chunchenhsu@google.com>
Reviewed-on: https://gem5-review.googlesource.com/9101
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>

src/arch/arm/isa/formats/aarch64.isa
src/arch/isa_parser.py

index 1b9a86cad80d4b0201ae81bddac38fbb4e288773..7752ba08f82f8e6e31c471db9e1ae31e033e55cc 100644 (file)
@@ -1897,6 +1897,7 @@ namespace Aarch64
                         return new Unknown64(machInst);
                     }
                 }
+                M5_UNREACHABLE;
               case 0x1:
               {
                 if (bits(machInst, 31) ||
@@ -2005,7 +2006,7 @@ namespace Aarch64
                 M5_UNREACHABLE;
             }
         }
-        return new FailUnimplemented("Unhandled Case4", machInst);
+        M5_UNREACHABLE;
     }
 }
 }};
index 68173498542401d987fa18a13622971ea34ca7ef..a65149fe086c3ab53c0c32ab9354113efbc72ca6 100755 (executable)
@@ -1565,6 +1565,9 @@ class ISAParser(Grammar):
         # decoder method - cannot be split
         file = 'decoder.cc'
         with self.open(file) as f:
+            fn = 'base/compiler.hh'
+            f.write('#include "%s"\n' % fn)
+
             fn = 'decoder-g.cc.inc'
             assert(fn in self.files)
             f.write('#include "%s"\n' % fn)
@@ -2206,7 +2209,8 @@ StaticInstPtr
         codeObj = t[3]
         # just wrap the decoding code from the block as a case in the
         # outer switch statement.
-        codeObj.wrap_decode_block('\n%s\n' % ''.join(case_list))
+        codeObj.wrap_decode_block('\n%s\n' % ''.join(case_list),
+                                  'M5_UNREACHABLE;\n')
         codeObj.has_decode_default = (case_list == ['default:'])
         t[0] = codeObj