add --strict option (replacing STRICT_C99 define)
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sat, 8 Dec 2007 08:42:10 +0000 (08:42 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sat, 8 Dec 2007 08:42:10 +0000 (08:42 +0000)
[r18646]

lang_features.h
main.c
parser.c

index 8113d3e..101aa45 100644 (file)
@@ -19,4 +19,7 @@ extern unsigned int machine_size;
 /* true if the char type is signed */
 extern bool char_is_signed;
 
+/* true for strict language checking. */
+extern bool strict_mode;
+
 #endif
diff --git a/main.c b/main.c
index 1a14476..1f16d01 100644 (file)
--- a/main.c
+++ b/main.c
@@ -79,6 +79,9 @@ unsigned int machine_size = 32;
 /** true if the char type is signed. */
 bool char_is_signed = true;
 
+/** true for strict language checking. */
+bool strict_mode = false;
+
 static int            verbose;
 static struct obstack cppflags_obst;
 
@@ -368,6 +371,8 @@ int main(int argc, char **argv)
                        char_is_signed = true;
                } else if(strcmp(arg, "--unsigned-chars") == 0) {
                        char_is_signed = false;
+               } else if(strcmp(arg, "--strict") == 0) {
+                       strict_mode = true;
                } else if(strcmp(arg, "--no-ms") == 0) {
                        c_mode &= ~_MS;
                } else if(strcmp(arg, "--lextest") == 0) {
index 3c37a9c..4dec832 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -13,6 +13,7 @@
 #include "type_t.h"
 #include "type_hash.h"
 #include "ast_t.h"
+#include "lang_features.h"
 #include "adt/bitfiddle.h"
 #include "adt/error.h"
 #include "adt/array.h"
@@ -20,7 +21,6 @@
 //#define PRINT_TOKENS
 //#define ABORT_ON_ERROR
 #define MAX_LOOKAHEAD 2
-//#define STRICT_C99
 
 typedef struct {
        declaration_t *old_declaration;
@@ -1850,13 +1850,13 @@ finish_specifiers:
                default:
                        /* invalid specifier combination, give an error message */
                        if(type_specifiers == 0) {
-#ifndef STRICT_C99
-                               warningf(HERE, "no type specifiers in declaration, using int");
-                               atomic_type = ATOMIC_TYPE_INT;
-                               break;
-#else
-                               errorf(HERE, "no type specifiers given in declaration");
-#endif
+                               if (! strict_mode) {
+                                       warningf(HERE, "no type specifiers in declaration, using int");
+                                       atomic_type = ATOMIC_TYPE_INT;
+                                       break;
+                               } else {
+                                       errorf(HERE, "no type specifiers given in declaration");
+                               }
                        } else if((type_specifiers & SPECIFIER_SIGNED) &&
                                  (type_specifiers & SPECIFIER_UNSIGNED)) {
                                errorf(HERE, "signed and unsigned specifiers gives");
@@ -2573,13 +2573,13 @@ static void parse_kr_declaration_list(declaration_t *declaration)
                        parameter_declaration = parameter_declaration->next) {
                type_t *parameter_type = parameter_declaration->type;
                if(parameter_type == NULL) {
-#ifdef STRICT_C99
-                       errorf(HERE, "no type specified for function parameter '%s'", parameter_declaration->symbol->string);
-#else
-                       warningf(HERE, "no type specified for function parameter '%s', using int", parameter_declaration->symbol->string);
-                       parameter_type              = type_int;
-                       parameter_declaration->type = parameter_type;
-#endif
+                       if (strict_mode) {
+                               errorf(HERE, "no type specified for function parameter '%s'", parameter_declaration->symbol->string);
+                       } else {
+                               warningf(HERE, "no type specified for function parameter '%s', using int", parameter_declaration->symbol->string);
+                               parameter_type              = type_int;
+                               parameter_declaration->type = parameter_type;
+                       }
                }
 
                semantic_parameter(parameter_declaration);
@@ -3027,16 +3027,13 @@ static expression_t *parse_reference(void)
        next_token();
 
        if(declaration == NULL) {
-#ifndef STRICT_C99
-               /* an implicitly defined function */
-               if(token.type == '(') {
+               if (! strict_mode && token.type == '(') {
+                       /* an implicitly defined function */
                        warningf(HERE, "implicit declaration of function '%s'\n", ref->symbol->string);
 
                        declaration = create_implicit_function(ref->symbol,
                                                               source_position);
-               } else
-#endif
-               {
+               } else {
                        errorf(HERE, "unknown symbol '%s' found.\n", ref->symbol->string);
                        return expression;
                }