]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/60139 (Imprecise column number for -pedantic on non-computable initializer...
authorMarek Polacek <polacek@redhat.com>
Wed, 30 Apr 2014 06:14:39 +0000 (06:14 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 30 Apr 2014 06:14:39 +0000 (06:14 +0000)
PR c/60139
* c-typeck.c (output_init_element): Pass OPT_Wpedantic to pedwarn
and pedwarn_init.  Use loc insted of input_location.

* gcc.dg/pr60139.c: New test.

From-SVN: r209926

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

index ee7c9bef05d0f3b6fac4fd44c33a6c6181707662..d54b62e11ea86c469af90bd672217a4cf2f9b748 100644 (file)
@@ -1,3 +1,9 @@
+2014-04-30  Marek Polacek  <polacek@redhat.com>
+
+       PR c/60139
+       * c-typeck.c (output_init_element): Pass OPT_Wpedantic to pedwarn
+       and pedwarn_init.  Use loc insted of input_location.
+
 2014-04-30  Marek Polacek  <polacek@redhat.com>
 
        PR c/60351
index e23c6dbbb0efadbf8d310071a3c15676af76dc2a..6e56b69ab5f9051951a52b24ea16a75f9186e9dc 100644 (file)
@@ -8255,12 +8255,12 @@ output_init_element (location_t loc, tree value, tree origtype,
          value = error_mark_node;
        }
       else if (require_constant_elements)
-       pedwarn (input_location, 0,
+       pedwarn (loc, OPT_Wpedantic,
                 "initializer element is not computable at load time");
     }
   else if (!maybe_const
           && (require_constant_value || require_constant_elements))
-    pedwarn_init (input_location, 0,
+    pedwarn_init (loc, OPT_Wpedantic,
                  "initializer element is not a constant expression");
 
   /* Issue -Wc++-compat warnings about initializing a bitfield with
index 79238530e15e11c6e7c4690cd7576ce08ad308b2..de105037daf126c6506bea7be40bebda5dda107e 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-30  Marek Polacek  <polacek@redhat.com>
+
+       PR c/60139
+       * gcc.dg/pr60139.c: New test.
+
 2014-04-30  Marek Polacek  <polacek@redhat.com>
 
        PR c/60351
diff --git a/gcc/testsuite/gcc.dg/pr60139.c b/gcc/testsuite/gcc.dg/pr60139.c
new file mode 100644 (file)
index 0000000..a63d8b5
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR c/60139 */
+/* { dg-do compile } */
+/* { dg-options "-Wpedantic" } */
+/* { dg-prune-output ".*near initialization for.*" } */
+
+double sin (double);
+void
+fn (int *p)
+{
+  int **a[] = { &p, /* { dg-warning "17:initializer element is not computable at load time" } */
+               (void *) 0, &p }; /* { dg-warning "28:initializer element is not computable at load time" } */
+  double d[] = { sin (1.0), /* { dg-warning "18:initializer element is not a constant expression" } */
+                 8.8, sin (1.0), 2.6 }; /* { dg-warning "23:initializer element is not a constant expression" } */
+}