This patch tweaks an error message a little bit so that we also print the
type we're talking about.

This is neither a regression nor a bug fix - should I queue this for GCC 6,
or is it so minor that it can still go into GCC 5?

Bootstrapped/regtested on ppc64-linux.

2015-02-13  Marek Polacek  <pola...@redhat.com>

        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.

diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index 48c2bcb..4fd3239 100644
--- gcc/c/c-decl.c
+++ 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 gcc/testsuite/gcc.dg/pr65050.c gcc/testsuite/gcc.dg/pr65050.c
index e69de29..0822a99 100644
--- gcc/testsuite/gcc.dg/pr65050.c
+++ 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}." } */

        Marek

Reply via email to