aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-04-30 09:28:48 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-04-30 09:28:48 +0000
commit9babc352483293e84371af273b1aa1be037cdf31 (patch)
tree183c206c1e7758eb0e2f52fb82d6947aff7124df /gcc
parentc064f154a65870a48131f699312d312b7ae1cc81 (diff)
downloadgcc-9babc352483293e84371af273b1aa1be037cdf31.zip
gcc-9babc352483293e84371af273b1aa1be037cdf31.tar.gz
gcc-9babc352483293e84371af273b1aa1be037cdf31.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-typeck.c2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/init-bad-8.c10
4 files changed, 20 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 6d8dbb1..0ee7f1b 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -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
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index c58e918..466079f 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 4c41b24..861077b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
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 0000000..b321323
--- /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" } */
+}