aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-02-13 22:07:36 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-02-13 22:07:36 +0000
commite5d9235ba945870c20a70499d5565edfb2bd4264 (patch)
tree50442a9d007f4a9fd04ac483f5f356867e8c3cd7
parentef796bef889d8a1590430a9da06c40ec4977d79e (diff)
downloadgcc-e5d9235ba945870c20a70499d5565edfb2bd4264.zip
gcc-e5d9235ba945870c20a70499d5565edfb2bd4264.tar.gz
gcc-e5d9235ba945870c20a70499d5565edfb2bd4264.tar.bz2
re PR c/65050 (Show the type for "array type has incomplete element type" error)
PR c/65050 * c-decl.c (grokdeclarator): Print also the type when giving the error message about array's incomplete element type. * gcc.dg/pr65050.c: New test. From-SVN: r220698
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr65050.c23
4 files changed, 36 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index ab917cb..08955a4 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-13 Marek Polacek <polacek@redhat.com>
+
+ PR c/65050
+ * c-decl.c (grokdeclarator): Print also the type when giving
+ the error message about array's incomplete element type.
+
2015-02-11 Jakub Jelinek <jakub@redhat.com>
PR c/64824
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 48c2bcb..4fd3239 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5962,7 +5962,8 @@ grokdeclarator (const struct c_declarator *declarator,
/* Complain about arrays of incomplete types. */
if (!COMPLETE_TYPE_P (type))
{
- error_at (loc, "array type has incomplete element type");
+ error_at (loc, "array type has incomplete element type %qT",
+ type);
type = error_mark_node;
}
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f700bb1..78026a1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-13 Marek Polacek <polacek@redhat.com>
+
+ PR c/65050
+ * gcc.dg/pr65050.c: New test.
+
2015-02-13 Jeff Law <law@redhat.com>
PR tree-optimization/64823
diff --git a/gcc/testsuite/gcc.dg/pr65050.c b/gcc/testsuite/gcc.dg/pr65050.c
new file mode 100644
index 0000000..0822a99
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr65050.c
@@ -0,0 +1,23 @@
+/* PR c/65050 */
+/* { dg-do compile } */
+
+typedef int A[];
+struct S { int i; A a[5]; } s; /* { dg-error "array type has incomplete element type .A {aka int\\\[\\\]}." } */
+extern void foo (int p[2][]); /* { dg-error "array type has incomplete element type .int\\\[\\\]." } */
+extern void bar (A p[2]); /* { dg-error "array type has incomplete element type .A {aka int\\\[\\\]}." } */
+
+void
+foo (int p[2][]) /* { dg-error "array type has incomplete element type .int\\\[\\\]." } */
+{
+}
+
+void
+bar (A p[2]) /* { dg-error "array type has incomplete element type .A {aka int\\\[\\\]}." } */
+{
+}
+
+struct T;
+struct T t[5]; /* { dg-error "array type has incomplete element type .struct T." } */
+struct U u[] = { { "abc" } }; /* { dg-error "array type has incomplete element type .struct U." } */
+typedef struct T TT;
+TT tt[5]; /* { dg-error "array type has incomplete element type .TT {aka struct T}." } */