From 935600fb9612ef569f1f68f60b0b7cdd57ce7af6 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Wed, 30 Oct 2019 14:38:00 +0000 Subject: Enable -Weverything Clang has a -Weverything option, that enables all compile-time warnings and elevates them all to errors. This option is now passed to the compiler, and all warnings/errors the code produced have been addressed. Using -Weverything locks the project into using clang as its compiler: this should not be a problem since clang is probably being used to compile the LLVM output of the project anyway. If support for other compilers is required, it should be simple enough to replace -Weverything with an equivalent collection of portable flags. Explicit Makefile rules for compiling the C files produced by flex/bison are now included in the project since these C files absolutely do not pass -Weverything checks. --- Makefile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9dbbb04..52ea0f7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,13 @@ -CFLAGS = --std=c99 -Wpedantic -Wall +CC = clang +CXX = clang++ +YACC = bison +LEX = flex + +DEBUG = -ggdb3 -O0 +RELEASE = -O3 -DNDEBUG + +CFLAGS = --std=c99 -Weverything +LFLAGS = -D_POSIX_C_SOURCE=200809L CFLAGS += $(shell llvm-config --cflags) CXXFLAGS += $(shell llvm-config --cppflags) @@ -17,9 +26,18 @@ scope.o: scope.h error.h basic: basic.o parse.o lex.o scope.o $(LINK.cc) $(OUTPUT_OPTION) $^ $(LDLIBS) -parse.h: parse.y - $(YACC) -d -o /dev/null $< - mv -f y.tab.h $@ +# explicit rules for parse and lex prevent -Weverything being passed to them +parse.o: parse.c + $(CC) -c --std=c99 $(OUTPUT_OPTION) $< + +lex.o: lex.c + $(CC) -c --std=c99 $(OUTPUT_OPTION) $< + +%.h: %.y + $(YACC) --defines=$@ $< + +%.c: %.y + $(YACC) -o $@ $< # test stuff (warning: influenced by compiler flags declared above!) # TODO should probably rearrange the system so tests don't use the same build -- cgit v1.2.1