n = finish_struct (input_location, n, fields, attributes, NULL,
&expr);
- n = qualify_type (n, t1);
-
- gcc_checking_assert (!TYPE_NAME (n) || comptypes (n, t1));
- gcc_checking_assert (!TYPE_NAME (n) || comptypes (n, t2));
-
- return n;
+ return qualify_type (n, t1);
}
/* FALLTHRU */
case ENUMERAL_TYPE:
composite_type (tree t1, tree t2)
{
struct composite_cache cache = { };
- return composite_type_internal (t1, t2, &cache);
+ tree n = composite_type_internal (t1, t2, &cache);
+ /* For function and arrays there are some cases where qualifiers do
+ not match. See PR120510. */
+ if (FUNCTION_TYPE != TREE_CODE (n) && ARRAY_TYPE != TREE_CODE (n))
+ {
+ gcc_checking_assert (comptypes (n, t1));
+ gcc_checking_assert (comptypes (n, t2));
+ }
+ return n;
}
/* Return the type of a conditional expression between pointers to
/* { dg-do compile } */
/* { dg-options "-std=gnu23" } */
+#define NEST(...) typeof(({ (__VA_ARGS__){ }; }))
+
int f()
{
typedef struct foo bar;
- struct foo { typeof(({ (struct foo { bar * x; }){ }; })) * x; } *q;
- typeof(q->x) p;
- 1 ? p : q;
+ struct foo { NEST(struct foo { bar *x; }) *x; } *q;
+ typeof(q->x) p0;
+ typeof(q->x) p1;
+ 1 ? p0 : q;
+ 1 ? p1 : q;
+ 1 ? p0 : p1;
+}
+
+int g()
+{
+ typedef struct fo2 bar;
+ struct fo2 { NEST(struct fo2 { NEST(struct fo2 { bar *x; }) * x; }) *x; } *q;
+ typeof(q->x) p0;
+ typeof(q->x->x) p1;
+ typeof(q->x->x->x) p2;
+ 1 ? p0 : q;
+ 1 ? p1 : q;
+ 1 ? p2 : q;
+ 1 ? p0 : p1;
+ 1 ? p2 : p1;
+ 1 ? p0 : p2;
}