aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-typeck.c13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/init-bad-6.c12
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d9eb79f..3bf728a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 4b9b2b3..9ce60cd 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1df4e70..20d0b4a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/gcc.dg/init-bad-6.c b/gcc/testsuite/gcc.dg/init-bad-6.c
new file mode 100644
index 0000000..8235f5d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/init-bad-6.c
@@ -0,0 +1,12 @@
+/* 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" } */