c-typeck.c (set_init_label): Call error_at instead of error and pass LOC to it.

* c-typeck.c (set_init_label): Call error_at instead of error and
	pass LOC to it.

	* gcc.dg/init-bad-8.c: New test.

From-SVN: r222613
This commit is contained in:
Marek Polacek 2015-04-30 09:28:48 +00:00 committed by Marek Polacek
parent c064f154a6
commit 9babc35248
4 changed files with 20 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2015-04-30 Marek Polacek <polacek@redhat.com>
* c-typeck.c (set_init_label): Call error_at instead of error and
pass LOC to it.
2015-04-29 Thomas Schwinge <thomas@codesourcery.com>
* c-parser.c (c_parser_oacc_enter_exit_data): Use

View File

@ -7926,7 +7926,7 @@ set_init_label (location_t loc, tree fieldname,
field = lookup_field (constructor_type, fieldname);
if (field == 0)
error ("unknown field %qE specified in initializer", fieldname);
error_at (loc, "unknown field %qE specified in initializer", fieldname);
else
do
{

View File

@ -1,3 +1,7 @@
2015-04-30 Marek Polacek <polacek@redhat.com>
* gcc.dg/init-bad-8.c: New test.
2015-04-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/59955

View File

@ -0,0 +1,10 @@
/* { dg-do compile } */
/* { dg-options "" } */
struct S { int i, j, k; };
void
foo (void)
{
struct S s = { .i = 1, .j = 2, .l = 4}; /* { dg-error "34:unknown field .l. specified in initializer" } */
}