Skip to content

Commit

Permalink
Make fallthroughs explicit and enable warnings around this
Browse files Browse the repository at this point in the history
  • Loading branch information
r-barnes committed Jul 30, 2024
1 parent 913281d commit 4b291dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH})
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR
${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(OPT "-O3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -std=c99 -O3 ${OPT}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++17 -fPIC ${OPT}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Wimplicit-fallthrough -pedantic -std=c99 -O3 ${OPT}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wimplicit-fallthrough -Woverloaded-virtual -pedantic -std=c++17 -fPIC ${OPT}")
else()
# TODO: Windows support.
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported")
Expand Down
2 changes: 1 addition & 1 deletion core/desugarer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ class Desugarer {
} break;

case BOP_MANIFEST_UNEQUAL: invert = true;
/* fallthrough */
[[fallthrough]];
case BOP_MANIFEST_EQUAL: {
ast_ = equals(ast->location, ast->left, ast->right);
if (invert)
Expand Down
2 changes: 1 addition & 1 deletion core/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ class Interpreter {
stack.top().val2 = scratch;
stack.top().kind = FRAME_BINARY_OP;
}
// Falls through.
[[fallthrough]];
case FRAME_BINARY_OP: {
const auto &ast = *static_cast<const Binary *>(f.ast);
const Value &lhs = stack.top().val;
Expand Down

0 comments on commit 4b291dd

Please sign in to comment.