Commit d9b7be2e by Marek Polacek Committed by Marek Polacek

re PR c/63543 (incomplete type error should suppress duplicates)

	PR c/63543
	* c-tree.h (C_TYPE_ERROR_REPORTED): Define.
	* c-typeck.c (build_indirect_ref): Don't print the "dereferencing..."
	error multiple times.  Print the type.

	* gcc.dg/pr63543.c: New test.
	* gcc.dg/array-8.c: Remove dg-error.
	* gcc.dg/pr48552-1.c: Remove and adjust dg-error.
	* gcc.dg/pr48552-2.c: Likewise.

From-SVN: r216414
parent f406ae1f
2014-10-17 Marek Polacek <polacek@redhat.com>
PR c/63543
* c-tree.h (C_TYPE_ERROR_REPORTED): Define.
* c-typeck.c (build_indirect_ref): Don't print the "dereferencing..."
error multiple times. Print the type.
2014-10-17 Marek Polacek <polacek@redhat.com>
PR c/63549
* c-typeck.c (build_array_ref): Bail if the index in an incomplete
type.
......
......@@ -56,6 +56,9 @@ along with GCC; see the file COPYING3. If not see
This is used for -Wc++-compat. */
#define C_TYPE_DEFINED_IN_STRUCT(TYPE) TYPE_LANG_FLAG_2 (TYPE)
/* Record whether an "incomplete type" error was given for the type. */
#define C_TYPE_ERROR_REPORTED(TYPE) TYPE_LANG_FLAG_3 (TYPE)
/* Record whether a typedef for type `int' was actually `signed int'. */
#define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
......
......@@ -2378,7 +2378,12 @@ build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE)
{
error_at (loc, "dereferencing pointer to incomplete type");
if (!C_TYPE_ERROR_REPORTED (TREE_TYPE (ptr)))
{
error_at (loc, "dereferencing pointer to incomplete type "
"%qT", t);
C_TYPE_ERROR_REPORTED (TREE_TYPE (ptr)) = 1;
}
return error_mark_node;
}
if (VOID_TYPE_P (t) && c_inhibit_evaluation_warnings == 0)
......
2014-10-17 Marek Polacek <polacek@redhat.com>
PR c/63543
* gcc.dg/pr63543.c: New test.
* gcc.dg/array-8.c: Remove dg-error.
* gcc.dg/pr48552-1.c: Remove and adjust dg-error.
* gcc.dg/pr48552-2.c: Likewise.
2014-10-17 Marek Polacek <polacek@redhat.com>
PR c/63549
* gcc.dg/pr63549.c: New test.
......
......@@ -45,5 +45,4 @@ g (void)
sip[0]; /* { dg-error "invalid use of undefined type 'struct si'" } */
/* { dg-error "dereferencing pointer to incomplete type" "incomplete" { target *-*-* } 45 } */
0[sip]; /* { dg-error "invalid use of undefined type 'struct si'" } */
/* { dg-error "dereferencing pointer to incomplete type" "incomplete" { target *-*-* } 47 } */
}
......@@ -49,5 +49,5 @@ f7 (struct S *x)
void
f8 (struct S *x)
{
__asm volatile ("" : "=r" (*x)); /* { dg-error "dereferencing pointer to incomplete type" "incomplete" } */
} /* { dg-error "invalid lvalue in asm output 0" "invalid lvalue" { target *-*-* } 52 } */
__asm volatile ("" : "=r" (*x)); /* { dg-error "invalid lvalue in asm output 0" } */
}
......@@ -49,5 +49,5 @@ f7 (struct S *x)
void
f8 (struct S *x)
{
__asm ("" : "=r" (*x)); /* { dg-error "dereferencing pointer to incomplete type" "incomplete" } */
} /* { dg-error "invalid lvalue in asm output 0" "invalid lvalue" { target *-*-* } 52 } */
__asm ("" : "=r" (*x)); /* { dg-error "invalid lvalue in asm output 0" } */
}
/* PR c/63543 */
/* { dg-do compile } */
struct S;
union U;
int
f1 (struct S *s)
{
return s->a /* { dg-error "dereferencing pointer to incomplete type .struct S." } */
+ s->b
+ s->c;
}
int
f2 (union U *u)
{
return u->a /* { dg-error "dereferencing pointer to incomplete type .union U." } */
+ u->a
+ u->a;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment