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. --- basic.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'basic.h') diff --git a/basic.h b/basic.h index a270130..13c375d 100644 --- a/basic.h +++ b/basic.h @@ -1,10 +1,16 @@ -#ifndef _BASIC_H -#define _BASIC_H +#ifndef BASIC_H +#define BASIC_H + +/* + * This struct being padded is unimportant. + */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" typedef struct sexpr { int type; union contents { - float f; + double f; char *s; int i; struct node { @@ -14,11 +20,13 @@ typedef struct sexpr { } contents; } sexpr; +#pragma clang diagnostic pop + typedef struct node node; typedef union contents contents; sexpr *new_int(int num); -sexpr *new_float(float num); +sexpr *new_float(double num); sexpr *new_id(char *id); sexpr *new_node(sexpr *l, sexpr *r); sexpr *new_str(char *str); @@ -28,4 +36,4 @@ void fprint_sexpr(FILE *f, sexpr *se); void codegen(sexpr *sexpr); -#endif /* _BASIC_H */ +#endif /* BASIC_H */ -- cgit v1.2.1