From: Marek Polacek Date: Wed, 30 Apr 2014 06:14:39 +0000 (+0000) Subject: re PR c/60139 (Imprecise column number for -pedantic on non-computable initializer... X-Git-Tag: releases/gcc-5.1.0~7854 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8337d1db7113fa0c44541a1917529a0c41057a4a;p=thirdparty%2Fgcc.git re PR c/60139 (Imprecise column number for -pedantic on non-computable initializer element) 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 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ee7c9bef05d0..d54b62e11ea8 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-04-30 Marek Polacek + + 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 PR c/60351 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index e23c6dbbb0ef..6e56b69ab5f9 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 79238530e15e..de105037daf1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-04-30 Marek Polacek + + PR c/60139 + * gcc.dg/pr60139.c: New test. + 2014-04-30 Marek Polacek PR c/60351 diff --git a/gcc/testsuite/gcc.dg/pr60139.c b/gcc/testsuite/gcc.dg/pr60139.c new file mode 100644 index 000000000000..a63d8b5b9bdf --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr60139.c @@ -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" } */ +}