Skip to content

Commit 2b0122c

Browse files
authored
Make fallthroughs explicit and enable warnings around this (#1161)
1 parent a02a615 commit 2b0122c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH})
3636
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR
3737
${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
3838
set(OPT "-O3")
39-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -std=c99 -O3 ${OPT}")
40-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++17 -fPIC ${OPT}")
39+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Wimplicit-fallthrough -pedantic -std=c99 -O3 ${OPT}")
40+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wimplicit-fallthrough -Woverloaded-virtual -pedantic -std=c++17 -fPIC ${OPT}")
4141
else()
4242
# TODO: Windows support.
4343
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported")

core/desugarer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ class Desugarer {
732732
} break;
733733

734734
case BOP_MANIFEST_UNEQUAL: invert = true;
735-
/* fallthrough */
735+
[[fallthrough]];
736736
case BOP_MANIFEST_EQUAL: {
737737
ast_ = equals(ast->location, ast->left, ast->right);
738738
if (invert)

core/vm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ class Interpreter {
23902390
stack.top().val2 = scratch;
23912391
stack.top().kind = FRAME_BINARY_OP;
23922392
}
2393-
// Falls through.
2393+
[[fallthrough]];
23942394
case FRAME_BINARY_OP: {
23952395
const auto &ast = *static_cast<const Binary *>(f.ast);
23962396
const Value &lhs = stack.top().val;

0 commit comments

Comments
 (0)