Commit f6294de7 by Joseph Myers Committed by Joseph Myers

re PR c/35433 (ICE with typeof and ternary operator)

	PR c/35433
	* c-typeck.c (composite_type): Set TYPE_SIZE and TYPE_SIZE_UNIT
	for composite type involving a zero-length array type.

testsuite:
	* gcc.dg/init-bad-6.c: New test.

From-SVN: r143906
parent 1056e649
2009-02-03 Joseph Myers <joseph@codesourcery.com>
PR c/35433
* c-typeck.c (composite_type): Set TYPE_SIZE and TYPE_SIZE_UNIT
for composite type involving a zero-length array type.
2009-02-03 Jakub Jelinek <jakub@redhat.com>
PR target/35318
......
......@@ -326,10 +326,14 @@ composite_type (tree t1, tree t2)
tree d2 = TYPE_DOMAIN (t2);
bool d1_variable, d2_variable;
bool d1_zero, d2_zero;
bool t1_complete, t2_complete;
/* We should not have any type quals on arrays at all. */
gcc_assert (!TYPE_QUALS (t1) && !TYPE_QUALS (t2));
t1_complete = COMPLETE_TYPE_P (t1);
t2_complete = COMPLETE_TYPE_P (t2);
d1_zero = d1 == 0 || !TYPE_MAX_VALUE (d1);
d2_zero = d2 == 0 || !TYPE_MAX_VALUE (d2);
......@@ -369,6 +373,15 @@ composite_type (tree t1, tree t2)
|| !d1_variable))
? t1
: t2));
/* Ensure a composite type involving a zero-length array type
is a zero-length type not an incomplete type. */
if (d1_zero && d2_zero
&& (t1_complete || t2_complete)
&& !COMPLETE_TYPE_P (t1))
{
TYPE_SIZE (t1) = bitsize_zero_node;
TYPE_SIZE_UNIT (t1) = size_zero_node;
}
t1 = c_build_qualified_type (t1, quals);
return build_type_attribute_variant (t1, attributes);
}
......
2009-02-03 Joseph Myers <joseph@codesourcery.com>
PR c/35433
* gcc.dg/init-bad-6.c: New test.
2009-02-03 Jakub Jelinek <jakub@redhat.com>
PR target/35318
......
/* ICE arising from bug computing composite type of zero-length array
types: PR 35433. */
/* { dg-do compile } */
/* { dg-options "" } */
typedef int* X;
typedef int* Y;
X (*p)[][0];
Y (*q)[][0];
typeof(*(0 ? p : q)) x = { 0 }; /* { dg-warning "excess elements in array initializer|near initialization" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment