* c-typeck.c (set_init_label): Call error_at instead of error and
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 30 Apr 2015 09:28:48 +0000 (09:28 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 30 Apr 2015 09:28:48 +0000 (09:28 +0000)
pass LOC to it.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222613 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/init-bad-8.c [new file with mode: 0644]

index 6d8dbb1..0ee7f1b 100644 (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
index c58e918..466079f 100644 (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
       {
index 4c41b24..861077b 100644 (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
diff --git a/gcc/testsuite/gcc.dg/init-bad-8.c b/gcc/testsuite/gcc.dg/init-bad-8.c
new file mode 100644 (file)
index 0000000..b321323
--- /dev/null
@@ -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" } */
+}