Pretend the error type is compatible with every type, to suppress stray errors. ...
authorChristoph Mallon <christoph.mallon@gmx.de>
Sun, 14 Sep 2008 16:58:33 +0000 (16:58 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sun, 14 Sep 2008 16:58:33 +0000 (16:58 +0000)
[r21944]

parser.c
type.c

index 3c10013..cc84962 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -4452,8 +4452,9 @@ static declaration_t *record_declaration(
                        if (old_storage_class == STORAGE_CLASS_EXTERN &&
                                        new_storage_class == STORAGE_CLASS_EXTERN) {
 warn_redundant_declaration:
-                               if (!is_definition          &&
-                                   warning.redundant_decls &&
+                               if (!is_definition           &&
+                                   warning.redundant_decls  &&
+                                   is_type_valid(prev_type) &&
                                    strcmp(previous_declaration->source_position.input_name, "<builtin>") != 0) {
                                        warningf(&declaration->source_position,
                                                 "redundant declaration for '%Y' (declared %P)",
@@ -4471,14 +4472,16 @@ warn_redundant_declaration:
                                } else {
                                        goto warn_redundant_declaration;
                                }
-                       } else if (old_storage_class == new_storage_class) {
-                               errorf(&declaration->source_position,
-                                      "redeclaration of '%Y' (declared %P)",
-                                      symbol, &previous_declaration->source_position);
-                       } else {
-                               errorf(&declaration->source_position,
-                                      "redeclaration of '%Y' with different linkage (declared %P)",
-                                      symbol, &previous_declaration->source_position);
+                       } else if (is_type_valid(prev_type)) {
+                               if (old_storage_class == new_storage_class) {
+                                       errorf(&declaration->source_position,
+                                              "redeclaration of '%Y' (declared %P)",
+                                              symbol, &previous_declaration->source_position);
+                               } else {
+                                       errorf(&declaration->source_position,
+                                              "redeclaration of '%Y' with different linkage (declared %P)",
+                                              symbol, &previous_declaration->source_position);
+                               }
                        }
                }
 
diff --git a/type.c b/type.c
index a8705a4..bab541f 100644 (file)
--- a/type.c
+++ b/type.c
@@ -1084,6 +1084,9 @@ bool types_compatible(const type_t *type1, const type_t *type2)
        if (type1 == type2)
                return true;
 
+       if (!is_type_valid(type1) || !is_type_valid(type2))
+               return true;
+
        if (type1->base.qualifiers != type2->base.qualifiers)
                return false;
        if (type1->kind != type2->kind)