From: Marek Polacek Date: Thu, 30 Apr 2015 09:28:48 +0000 (+0000) Subject: c-typeck.c (set_init_label): Call error_at instead of error and pass LOC to it. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9babc352483293e84371af273b1aa1be037cdf31;p=gcc.git 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 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 6d8dbb1b135..0ee7f1bb823 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2015-04-30 Marek Polacek + + * c-typeck.c (set_init_label): Call error_at instead of error and + pass LOC to it. + 2015-04-29 Thomas Schwinge * c-parser.c (c_parser_oacc_enter_exit_data): Use diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index c58e9181f0e..466079f42c5 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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 { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c41b242417..861077bab8b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-04-30 Marek Polacek + + * gcc.dg/init-bad-8.c: New test. + 2015-04-30 Paolo Carlini PR c++/59955 diff --git a/gcc/testsuite/gcc.dg/init-bad-8.c b/gcc/testsuite/gcc.dg/init-bad-8.c new file mode 100644 index 00000000000..b321323219c --- /dev/null +++ b/gcc/testsuite/gcc.dg/init-bad-8.c @@ -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" } */ +}