]> gcc.gnu.org Git - gcc.git/commitdiff
c-typeck.c (set_init_label): Call error_at instead of error and pass LOC to it.
authorMarek Polacek <polacek@redhat.com>
Thu, 30 Apr 2015 09:28:48 +0000 (09:28 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 30 Apr 2015 09:28:48 +0000 (09:28 +0000)
* 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

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 6d8dbb1b1356c137813da566e13e0853f7c73acc..0ee7f1bb8232514e422d9cc4ae64b39ccac9a426 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 c58e9181f0e6fa7f5d853b2544bf84f532bfab74..466079f42c5372f4bf0d95f95991d8857418e928 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 4c41b242417674dcad7158aaeb666a9ef408e7cd..861077bab8bbd44271a22f7634c6266a7455738d 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" } */
+}
This page took 0.089086 seconds and 5 git commands to generate.