From 778564e63bfe93a32a2c449667507588a9070030 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 14 Sep 2017 23:28:02 -0400 Subject: [PATCH] Compling: Turn on -Wextra when using --enable-ccwarn --- configure.ac | 12 ++++++++++-- include/verilated.mk.in | 5 +++-- src/Makefile_obj.in | 4 +++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index bc97d4c2b..7c57ce62e 100644 --- a/configure.ac +++ b/configure.ac @@ -140,15 +140,22 @@ AC_DEFUN([_MY_CXX_CHECK_OPT], CXXFLAGS="$ACO_SAVE_CXXFLAGS" ])# _MY_CXX_CHECK_OPT -# Flags for compiling Verilator internals including parser +# Flags for compiling Verilator internals including parser, and Verilated files +# These turn on extra warnings and are only used with 'configure --enable-ccwarn' +_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wextra) +_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wlogical-op) +AC_SUBST(CFG_CXXFLAGS_WEXTRA) + +# Flags for compiling Verilator internals including parser always _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Qunused-arguments) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-faligned-new) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-delete-null-pointer-checks) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-unused-parameter) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-undefined-bool-conversion) +_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-shadow) AC_SUBST(CFG_CXXFLAGS_SRC) -# Flags for compiling Verilator parser (in addition to above CFG_CXXFLAGS_SRC) +# Flags for compiling Verilator parser always (in addition to above CFG_CXXFLAGS_SRC) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_PARSER,-Wno-char-subscripts) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_PARSER,-Wno-null-conversion) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_PARSER,-Wno-parentheses-equality) @@ -170,6 +177,7 @@ _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_NO_UNUSED,-Wno-uninitialized) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_NO_UNUSED,-Wno-unused-but-set-variable) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_NO_UNUSED,-Wno-unused-parameter) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_NO_UNUSED,-Wno-unused-variable) +_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_NO_UNUSED,-Wno-shadow) AC_SUBST(CFG_CXXFLAGS_NO_UNUSED) # Checks for library functions. diff --git a/include/verilated.mk.in b/include/verilated.mk.in index 0df6c3981..6c17ef03d 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -18,6 +18,8 @@ CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@ # Compiler flags to use to turn off unused and generated code warnings, such as -Wno-div-by-zero CFG_CXXFLAGS_NO_UNUSED = @CFG_CXXFLAGS_NO_UNUSED@ +# Compiler flags that turn on extra warnings +CFG_CXXFLAGS_WEXTRA = @CFG_CXXFLAGS_WEXTRA@ ###################################################################### # Programs @@ -48,8 +50,7 @@ VK_CPPFLAGS_ALWAYS += \ $(CFG_CXXFLAGS_NO_UNUSED) \ ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users -VK_CPPFLAGS_WALL += -Wall \ - -Werror +VK_CPPFLAGS_WALL += -Wall $(CFG_CXXFLAGS_WEXTRA) -Werror endif CPPFLAGS += -I. $(VK_CPPFLAGS_WALL) $(VK_CPPFLAGS_ALWAYS) diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 64f93de63..76578821a 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -64,6 +64,8 @@ LDFLAGS += @LDFLAGS@ EXEEXT = @EXEEXT@ CFG_CXXFLAGS_SRC = @CFG_CXXFLAGS_SRC@ CFG_CXXFLAGS_PARSER = @CFG_CXXFLAGS_PARSER@ +# Compiler flags that turn on extra warnings +CFG_CXXFLAGS_WEXTRA = @CFG_CXXFLAGS_WEXTRA@ #### End of system configuration section. #### @@ -97,7 +99,7 @@ CPPFLAGS += -DYYDEBUG # Required to get nice error messages CPPFLAGS += $(COPT) CPPFLAGS += -MP # Only works on recent GCC versions ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users -CPPFLAGS += -W -Wall $(CFG_CXXFLAGS_SRC) -Werror +CPPFLAGS += -W -Wall $(CFG_CXXFLAGS_WEXTRA) $(CFG_CXXFLAGS_SRC) -Werror #CPPFLAGS += -pedantic-errors else CPPFLAGS += $(CFG_CXXFLAGS_SRC)