diff options
author | Sam Clegg <sbc@chromium.org> | 2023-02-26 17:39:17 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-27 01:39:17 +0000 |
commit | 546d42a6ce52e67270ed7957b249bc59b4b57a1b (patch) | |
tree | b327c19a95710df8be60716220d6630bf01b7b47 | |
parent | 3d9ec159cb362d71cf76938d583841975b3e730a (diff) | |
download | wabt-546d42a6ce52e67270ed7957b249bc59b4b57a1b.tar.gz wabt-546d42a6ce52e67270ed7957b249bc59b4b57a1b.tar.bz2 wabt-546d42a6ce52e67270ed7957b249bc59b4b57a1b.zip |
Use C++17's [[fallthrough]]. NFC (#2091)
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/binary-reader-objdump.cc | 1 | ||||
-rw-r--r-- | src/binary-reader.cc | 2 | ||||
-rw-r--r-- | src/error-formatter.cc | 2 | ||||
-rw-r--r-- | src/prebuilt/lexer-keywords.cc | 26 |
5 files changed, 20 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 48812d13..2bfe62a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,7 +164,7 @@ else () # interfaces, etc. # disable -Wpointer-arith: this is a GCC extension, and doesn't work in MSVC. add_definitions( - -Wall -Wextra -Wno-unused-parameter -Wpointer-arith -Wuninitialized + -Wall -Wextra -Wno-unused-parameter -Wpointer-arith -Wuninitialized -Wimplicit-fallthrough ) set(CMAKE_CXX_EXTENSIONS OFF) @@ -563,7 +563,9 @@ if (BUILD_TOOLS) if (COMPILER_IS_GNU) target_compile_options(uv_a PRIVATE "-Wno-sign-compare") - endif () + elseif (COMPILER_IS_CLANG) + target_compile_options(uv_a PRIVATE "-Wno-implicit-fallthrough") + endif() endif() # wasm-interp diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 23f2016f..905647f4 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -691,6 +691,7 @@ void BinaryReaderObjdumpDisassemble::LogOpcode(const char* fmt, ...) { case Opcode::Catch: case Opcode::CatchAll: indent_level--; + break; default: break; } diff --git a/src/binary-reader.cc b/src/binary-reader.cc index 0c399461..0e0b894a 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -1719,7 +1719,7 @@ Result BinaryReader::ReadInstructions(bool stop_on_end, case Opcode::DataDrop: ERROR_IF(data_count_ == kInvalidIndex, "data.drop requires data count section"); - // Fallthrough. + [[fallthrough]]; case Opcode::ElemDrop: { Index segment; CHECK_RESULT(ReadIndex(&segment, "segment index")); diff --git a/src/error-formatter.cc b/src/error-formatter.cc index 5b0d4952..9a14cfac 100644 --- a/src/error-formatter.cc +++ b/src/error-formatter.cc @@ -94,7 +94,7 @@ std::string FormatErrorsToString(const Errors& errors, break; case PrintHeader::Once: print_header = PrintHeader::Never; - // Fallthrough. + [[fallthrough]]; case PrintHeader::Always: result += header; result += ":\n"; diff --git a/src/prebuilt/lexer-keywords.cc b/src/prebuilt/lexer-keywords.cc index bb7152fc..4a7da0e0 100644 --- a/src/prebuilt/lexer-keywords.cc +++ b/src/prebuilt/lexer-keywords.cc @@ -96,55 +96,55 @@ Perfect_Hash::hash (const char *str, size_t len) { default: hval += asso_values[static_cast<unsigned char>(str[26])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 26: case 25: case 24: case 23: hval += asso_values[static_cast<unsigned char>(str[22])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 22: case 21: case 20: case 19: hval += asso_values[static_cast<unsigned char>(str[18])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 18: hval += asso_values[static_cast<unsigned char>(str[17])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 17: hval += asso_values[static_cast<unsigned char>(str[16])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 16: case 15: hval += asso_values[static_cast<unsigned char>(str[14])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 14: case 13: case 12: hval += asso_values[static_cast<unsigned char>(str[11])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 11: case 10: hval += asso_values[static_cast<unsigned char>(str[9])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 9: case 8: hval += asso_values[static_cast<unsigned char>(str[7])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 7: hval += asso_values[static_cast<unsigned char>(str[6])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 6: hval += asso_values[static_cast<unsigned char>(str[5])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 5: hval += asso_values[static_cast<unsigned char>(str[4])]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 4: case 3: hval += asso_values[static_cast<unsigned char>(str[2]+1)]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 2: case 1: hval += asso_values[static_cast<unsigned char>(str[0]+1)]; |