get_aka_type will create a new type for diagnostics, but for tagged types
attributes will then be ignored with a warning. This can lead to reentering
warning code which leads to an ICE. Fix this by ignoring the attributes
for tagged types.
PR c/120380
gcc/c/ChangeLog:
* c-objc-common.cc (get_aka_type): Ignore attributes for tagged types.
gcc/testsuite/ChangeLog:
* gcc.dg/pr120380.c: New test.
return canonical ? canonical : type;
}
}
+ /* For tagged types ignore attributes because they will otherwise
+ be ignored later causing a warning inside diagnostics which leads
+ to an ICE. */
+ if (RECORD_OR_UNION_TYPE_P (type) || TREE_CODE (type) == ENUMERAL_TYPE)
+ return build_qualified_type (result, TYPE_QUALS (type));
return build_type_attribute_qual_variant (result, TYPE_ATTRIBUTES (type),
TYPE_QUALS (type));
}
--- /dev/null
+/* PR c/120380 */
+/* { dg-do compile } */
+
+struct pair_t {
+ char c;
+ int i;
+};
+typedef struct foo_ { /* { dg-error "no member" } */
+ struct foo_ { /* { dg-error "nested redefinition" } */
+ /* { dg-error "no member" "" { target *-*-* } .-1 } */
+ struct foo_ { /* { dg-error "nested redefinition" } */
+ int value;
+ }
+ } /* { dg-error "does not declare anything" } */
+ /* { dg-error "no semicolon" "" { target *-*-* } .-1 } */
+} __attribute__((packed)) foo; /* { dg-error "does not declare anything" } */
+ /* { dg-error "no semicolon" "" { target *-*-* } .-1 } */
+struct pair_t p = {0, 1};
+foo *addr = (foo *)&p.i;
+int main() {
+ addr->value = 0; /* { dg-error "has no member" } */
+ return 0;
+}
+