re PR c/65050 (Show the type for "array type has incomplete element type" error)
authorMarek Polacek <polacek@redhat.com>
Fri, 13 Feb 2015 22:07:36 +0000 (22:07 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 13 Feb 2015 22:07:36 +0000 (22:07 +0000)
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

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr65050.c [new file with mode: 0644]

index ab917cb9357f5f55c9f3a8f9ab52a11da10768e3..08955a4599933cbb159fbc8eeb9cc4278a03f1db 100644 (file)
@@ -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
index 48c2bcbf8bb4730c8d9159c6e9859a5b3039d973..4fd3239da89b6773a0047034b45182653c8e2c24 100644 (file)
@@ -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
index f700bb1d2271cf18fddd070e93713c5e07c30a96..78026a1015ed00ea2ed0dee3e5671af416fe621d 100644 (file)
@@ -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 (file)
index 0000000..0822a99
--- /dev/null
@@ -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}." } */