From dfaf6ad0715bc4973955d085c40f13340971529b Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 30 Apr 2024 08:08:26 -0700 Subject: [PATCH] Insert apparently-missing `break;` in IREquality.cpp (#8211) * Insert apparently-missing `break;` in IREquality.cpp * Enable -Wimplicit-fallthrough * Also add -Wimplicit-fallthrough to runtime builds * Add missing break to runtime/webgpu.cpp * Also add flag to Makefile --------- Co-authored-by: Andrew Adams --- CMakeLists.txt | 1 + Makefile | 2 +- src/IREquality.cpp | 1 + src/runtime/CMakeLists.txt | 1 + src/runtime/webgpu.cpp | 2 ++ 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b6fb85841c8..287ec4496f6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,7 @@ function(set_halide_compiler_warnings NAME) $<$:-Wcast-qual> $<$:-Wignored-qualifiers> $<$:-Woverloaded-virtual> + $<$:-Wimplicit-fallthrough> $<$:-Wsuggest-override> diff --git a/Makefile b/Makefile index 440b307a920e..761dfb058b75 100644 --- a/Makefile +++ b/Makefile @@ -193,7 +193,7 @@ WITH_RTTI ?= $(if $(LLVM_HAS_NO_RTTI),, not-empty) RTTI_CXX_FLAGS=$(if $(WITH_RTTI), , -fno-rtti ) CXX_VERSION = $(shell $(CXX) --version | head -n1) -CXX_WARNING_FLAGS = -Wall -Werror -Wno-unused-function -Wcast-qual -Wignored-qualifiers -Wno-comment -Wsign-compare -Wno-unknown-warning-option -Wno-psabi -Wno-mismatched-new-delete +CXX_WARNING_FLAGS = -Wall -Werror -Wno-unused-function -Wcast-qual -Wignored-qualifiers -Wno-comment -Wsign-compare -Wno-unknown-warning-option -Wno-psabi -Wno-mismatched-new-delete -Wimplicit-fallthrough ifneq (,$(findstring g++,$(CXX_VERSION))) GCC_MAJOR_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion | cut -f1 -d.) GCC_MINOR_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion | cut -f2 -d.) diff --git a/src/IREquality.cpp b/src/IREquality.cpp index bb64c1035590..53090be7b94e 100644 --- a/src/IREquality.cpp +++ b/src/IREquality.cpp @@ -356,6 +356,7 @@ struct Comparer { case IRNodeType::GT: cmp(>::a); cmp(>::b); + break; case IRNodeType::GE: cmp(&GE::a); cmp(&GE::b); diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt index 039fae2d1b11..3366f2113969 100644 --- a/src/runtime/CMakeLists.txt +++ b/src/runtime/CMakeLists.txt @@ -167,6 +167,7 @@ set(RUNTIME_CXX_FLAGS -Wno-unused-function -Wvla -Wsign-compare + -Wimplicit-fallthrough ) option(Halide_CLANG_TIDY_BUILD "Generate fake compile jobs for runtime files when running clang-tidy." OFF) diff --git a/src/runtime/webgpu.cpp b/src/runtime/webgpu.cpp index aa4e3fb5a71f..0a0ae240eade 100644 --- a/src/runtime/webgpu.cpp +++ b/src/runtime/webgpu.cpp @@ -1025,6 +1025,7 @@ WEAK int halide_webgpu_run(void *user_context, switch (arg_type.bits) { case 1: { *(int32_t *)arg_out = *((int8_t *)arg_in); + break; } case 8: { *(int32_t *)arg_out = *((int8_t *)arg_in); @@ -1048,6 +1049,7 @@ WEAK int halide_webgpu_run(void *user_context, switch (arg_type.bits) { case 1: { *(uint32_t *)arg_out = *((uint8_t *)arg_in); + break; } case 8: { *(uint32_t *)arg_out = *((uint8_t *)arg_in);