From e5d9235ba945870c20a70499d5565edfb2bd4264 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 13 Feb 2015 22:07:36 +0000 Subject: [PATCH] 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 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-decl.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr65050.c | 23 +++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr65050.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ab917cb9357..08955a45999 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-02-13 Marek Polacek + + 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 PR c/64824 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 48c2bcbf8bb..4fd3239da89 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 f700bb1d227..78026a1015e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-13 Marek Polacek + + PR c/65050 + * gcc.dg/pr65050.c: New test. + 2015-02-13 Jeff Law 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 00000000000..0822a99dfda --- /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}." } */ -- 2.30.2