diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 47cf3cc3093..86372fa3035 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2014-06-09 Marek Polacek + + PR c/36446 + * c-typeck.c (error_init): Call inform instead of error_at. + (pedwarn_init): Call inform instead of pedwarn. + (warning_init): Call inform instead of warning_at. + 2014-06-07 Jan Hubicka * c-decl.c (merge_decls): Use set_decl_section_name. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index e4fa0c3b4bc..63bd65ee0be 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -5567,7 +5567,7 @@ error_init (location_t loc, const char *gmsgid) error_at (loc, gmsgid); ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); if (*ofwhat) - error_at (loc, "(near initialization for %qs)", ofwhat); + inform (loc, "(near initialization for %qs)", ofwhat); } /* Issue a pedantic warning for a bad initializer component. OPT is @@ -5579,12 +5579,13 @@ static void pedwarn_init (location_t location, int opt, const char *gmsgid) { char *ofwhat; + bool warned; /* The gmsgid may be a format string with %< and %>. */ - pedwarn (location, opt, gmsgid); + warned = pedwarn (location, opt, gmsgid); ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); - if (*ofwhat) - pedwarn (location, opt, "(near initialization for %qs)", ofwhat); + if (*ofwhat && warned) + inform (location, "(near initialization for %qs)", ofwhat); } /* Issue a warning for a bad initializer component. @@ -5597,12 +5598,13 @@ static void warning_init (location_t loc, int opt, const char *gmsgid) { char *ofwhat; + bool warned; /* The gmsgid may be a format string with %< and %>. */ - warning_at (loc, opt, gmsgid); + warned = warning_at (loc, opt, gmsgid); ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); - if (*ofwhat) - warning_at (loc, opt, "(near initialization for %qs)", ofwhat); + if (*ofwhat && warned) + inform (loc, "(near initialization for %qs)", ofwhat); } /* If TYPE is an array type and EXPR is a parenthesized string diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 06bdfa6d062..b307bd33215 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2014-06-09 Marek Polacek + + PR c/36446 + * gcc.dg/Wcxx-compat-6.c: Change dg-warning to dg-message. + * gcc.dg/array-2.c: Likewise. + * gcc.dg/array-const-2.c: Likewise. + * gcc.dg/ucnid-8.c: Likewise. + * gcc.dg/vla-init-1.c: Likewise. + * gcc.dg/array-const-3.c: Change dg-error to dg-message. + * gcc.dg/c99-flex-array-7.c: Likewise. + * gcc.dg/init-bad-1.c: Likewise. + * gcc.dg/init-bad-3.c: Likewise. + * gcc.dg/init-bad-2.c: Change dg-error and dg-warning to dg-message. + * gcc.dg/pedwarn-init.c: Add dg-warning. + * gcc.dg/pr53119.c: Remove dg-excess-errors. + 2014-06-09 Paolo Carlini PR c++/22556 diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-6.c b/gcc/testsuite/gcc.dg/Wcxx-compat-6.c index 2b327c4bf64..eee6768f0b6 100644 --- a/gcc/testsuite/gcc.dg/Wcxx-compat-6.c +++ b/gcc/testsuite/gcc.dg/Wcxx-compat-6.c @@ -109,4 +109,4 @@ f(enum E1 e1, enum E2 e2, struct s1 vs1, struct s1 *vp1) } /* Match all extra informative notes. */ -/* { dg-warning "near initialization for" "expected" { target *-*-* } 0 } */ +/* { dg-message "near initialization for" "expected" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/array-2.c b/gcc/testsuite/gcc.dg/array-2.c index 497c58666e6..6187500e37a 100644 --- a/gcc/testsuite/gcc.dg/array-2.c +++ b/gcc/testsuite/gcc.dg/array-2.c @@ -8,7 +8,7 @@ struct f { int w; int x[]; }; struct g { struct f f; }; struct g g1 = { { 0, { } } }; struct g g2 = { { 0, { 1 } } }; /* { dg-error "nested context" "nested" } */ - /* { dg-error "near init" "near" { target *-*-* } 10 } */ + /* { dg-message "near init" "near" { target *-*-* } 10 } */ struct h { int x[0]; int y; }; struct h h1 = { { 0 }, 1 }; /* { dg-warning "excess elements" "excess" } */ - /* { dg-warning "near init" "before end" { target *-*-* } 13 } */ + /* { dg-message "near init" "before end" { target *-*-* } 13 } */ diff --git a/gcc/testsuite/gcc.dg/array-const-2.c b/gcc/testsuite/gcc.dg/array-const-2.c index f6e2bd5bbfa..6f76955f20a 100644 --- a/gcc/testsuite/gcc.dg/array-const-2.c +++ b/gcc/testsuite/gcc.dg/array-const-2.c @@ -6,4 +6,4 @@ extern int i; int a[] = { [1 ? 1 : i] = 0 }; /* { dg-warning "array index in initializer is not an integer constant expression" } */ -/* { dg-warning "near initialization" "near init" { target *-*-* } 8 } */ +/* { dg-message "near initialization" "near init" { target *-*-* } 8 } */ diff --git a/gcc/testsuite/gcc.dg/array-const-3.c b/gcc/testsuite/gcc.dg/array-const-3.c index 5bb215cbd0f..036b0eae7bc 100644 --- a/gcc/testsuite/gcc.dg/array-const-3.c +++ b/gcc/testsuite/gcc.dg/array-const-3.c @@ -6,4 +6,4 @@ extern int i; int a[] = { [1 ? 1 : i] = 0 }; /* { dg-error "array index in initializer is not an integer constant expression" } */ -/* { dg-error "near initialization" "near init" { target *-*-* } 8 } */ +/* { dg-message "near initialization" "near init" { target *-*-* } 8 } */ diff --git a/gcc/testsuite/gcc.dg/c99-flex-array-7.c b/gcc/testsuite/gcc.dg/c99-flex-array-7.c index 8966e6cccc0..88018b03d7f 100644 --- a/gcc/testsuite/gcc.dg/c99-flex-array-7.c +++ b/gcc/testsuite/gcc.dg/c99-flex-array-7.c @@ -6,12 +6,12 @@ struct s { int a; char b[]; }; struct s a = { 0, "" }; /* { dg-error "initialization of a flexible array member" } */ -/* { dg-error "near init" "near init" { target *-*-* } 8 } */ +/* { dg-message "near init" "near init" { target *-*-* } 8 } */ struct s b = { 0, { 0 } }; /* { dg-error "initialization of a flexible array member" } */ -/* { dg-error "near init" "near init" { target *-*-* } 10 } */ +/* { dg-message "near init" "near init" { target *-*-* } 10 } */ struct s c = { 0, { } }; /* { dg-error "ISO C forbids empty initializer braces" } */ struct s d = { .b = "" }; /* { dg-error "initialization of a flexible array member" } */ -/* { dg-error "near init" "near init" { target *-*-* } 13 } */ +/* { dg-message "near init" "near init" { target *-*-* } 13 } */ struct s e = { .b = { 0 } }; /* { dg-error "initialization of a flexible array member" } */ -/* { dg-error "near init" "near init" { target *-*-* } 15 } */ +/* { dg-message "near init" "near init" { target *-*-* } 15 } */ struct s f = { .b = { } }; /* { dg-error "ISO C forbids empty initializer braces" } */ diff --git a/gcc/testsuite/gcc.dg/init-bad-1.c b/gcc/testsuite/gcc.dg/init-bad-1.c index cc808b752a9..6599de097db 100644 --- a/gcc/testsuite/gcc.dg/init-bad-1.c +++ b/gcc/testsuite/gcc.dg/init-bad-1.c @@ -19,27 +19,27 @@ char s1[1] = { "x" }; char t[1] = "xy"; /* { dg-warning "initializer-string for array of chars is too long" } */ char t1[1] = { "xy" }; /* { dg-warning "initializer-string for array of chars is too long" } */ char u[1] = { "x", "x" }; /* { dg-error "excess elements in char array initializer" } */ -/* { dg-error "near init" "near" { target *-*-* } 21 } */ +/* { dg-message "near init" "near" { target *-*-* } 21 } */ int i = { }; /* { dg-error "empty scalar initializer" } */ -/* { dg-error "near init" "near" { target *-*-* } 24 } */ +/* { dg-message "near init" "near" { target *-*-* } 24 } */ int j = { 1 }; int k = { 1, 2 }; /* { dg-warning "excess elements in scalar initializer" } */ -/* { dg-warning "near init" "near" { target *-*-* } 29 } */ +/* { dg-message "near init" "near" { target *-*-* } 29 } */ int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 32 } */ +/* { dg-message "near init" "near" { target *-*-* } 32 } */ int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 34 } */ +/* { dg-message "near init" "near" { target *-*-* } 34 } */ int a3[1] = { [0 ... 1] = 0 }; /* { dg-error "array index range in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 36 } */ +/* { dg-message "near init" "near" { target *-*-* } 36 } */ int a4[2] = { [1 ... 0] = 0 }; /* { dg-error "empty index range in initializer" } */ -/* { dg-error "near init" "near" { target *-*-* } 38 } */ +/* { dg-message "near init" "near" { target *-*-* } 38 } */ int a5[2] = { [0 ... 2] = 0 }; /* { dg-error "array index range in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 40 } */ +/* { dg-message "near init" "near" { target *-*-* } 40 } */ int a6[2] = { [-1 ... 1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 42 } */ +/* { dg-message "near init" "near" { target *-*-* } 42 } */ int a7[] = { [-1 ... 1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 44 } */ +/* { dg-message "near init" "near" { target *-*-* } 44 } */ diff --git a/gcc/testsuite/gcc.dg/init-bad-2.c b/gcc/testsuite/gcc.dg/init-bad-2.c index 1f0f78bc60b..e151709308c 100644 --- a/gcc/testsuite/gcc.dg/init-bad-2.c +++ b/gcc/testsuite/gcc.dg/init-bad-2.c @@ -11,7 +11,7 @@ void h(a) int a = 1; /* { dg-error "parameter 'a' is initialized" } */ { struct s x = { 0 }; /* { dg-error "variable 'x' has initializer but incomplete type" } */ - /* { dg-warning "excess elements|near init" "near" { target *-*-* } 13 } */ + /* { dg-message "excess elements|near init" "near" { target *-*-* } 13 } */ /* { dg-error "storage size" "size" { target *-*-* } 13 } */ } @@ -20,14 +20,14 @@ char s1[1] = { "x" }; char t[1] = "xy"; /* { dg-warning "initializer-string for array of chars is too long" } */ char t1[1] = { "xy" }; /* { dg-warning "initializer-string for array of chars is too long" } */ char u[1] = { "x", "x" }; /* { dg-error "excess elements in char array initializer" } */ -/* { dg-error "near init" "near" { target *-*-* } 22 } */ +/* { dg-message "near init" "near" { target *-*-* } 22 } */ int j = { 1 }; int k = { 1, 2 }; /* { dg-warning "excess elements in scalar initializer" } */ -/* { dg-warning "near init" "near" { target *-*-* } 27 } */ +/* { dg-message "near init" "near" { target *-*-* } 27 } */ int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 30 } */ +/* { dg-message "near init" "near" { target *-*-* } 30 } */ int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 32 } */ +/* { dg-message "near init" "near" { target *-*-* } 32 } */ diff --git a/gcc/testsuite/gcc.dg/init-bad-3.c b/gcc/testsuite/gcc.dg/init-bad-3.c index 109e65e3e4b..82a632a02bc 100644 --- a/gcc/testsuite/gcc.dg/init-bad-3.c +++ b/gcc/testsuite/gcc.dg/init-bad-3.c @@ -11,7 +11,7 @@ void h(a) int a = 1; /* { dg-error "parameter 'a' is initialized" } */ { struct s x = { 0 }; /* { dg-error "variable 'x' has initializer but incomplete type" } */ - /* { dg-error "excess elements|near init" "near" { target *-*-* } 13 } */ + /* { dg-message "excess elements|near init" "near" { target *-*-* } 13 } */ /* { dg-error "storage size" "size" { target *-*-* } 13 } */ } @@ -20,14 +20,14 @@ char s1[1] = { "x" }; char t[1] = "xy"; /* { dg-error "initializer-string for array of chars is too long" } */ char t1[1] = { "xy" }; /* { dg-error "initializer-string for array of chars is too long" } */ char u[1] = { "x", "x" }; /* { dg-error "excess elements in char array initializer" } */ -/* { dg-error "near init" "near" { target *-*-* } 22 } */ +/* { dg-message "near init" "near" { target *-*-* } 22 } */ int j = { 1 }; int k = { 1, 2 }; /* { dg-error "excess elements in scalar initializer" } */ -/* { dg-error "near init" "near" { target *-*-* } 27 } */ +/* { dg-message "near init" "near" { target *-*-* } 27 } */ int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 30 } */ +/* { dg-message "near init" "near" { target *-*-* } 30 } */ int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ -/* { dg-error "near init" "near" { target *-*-* } 32 } */ +/* { dg-message "near init" "near" { target *-*-* } 32 } */ diff --git a/gcc/testsuite/gcc.dg/pedwarn-init.c b/gcc/testsuite/gcc.dg/pedwarn-init.c index 12611154bee..e3181d62157 100644 --- a/gcc/testsuite/gcc.dg/pedwarn-init.c +++ b/gcc/testsuite/gcc.dg/pedwarn-init.c @@ -12,6 +12,7 @@ int a1 = { 1, 2 }; /* { dg-warning "15:excess elements in scalar initializer" } int a2[2] = { 1, 2, 3 }; /* { dg-warning "21:excess elements in array initializer" } */ int a3[] = { [1 ? 1 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */ int a4[] = { [1 ... 1 ? 2 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */ +/* { dg-warning "ISO C forbids" "ISO C" { target *-*-* } 14 } */ char a5[] = ("lol"); /* { dg-warning "13:array initialized from parenthesized string constant" } */ char a6[] = { ("foo") }; /* { dg-warning "13:array initialized from parenthesized string constant" } */ char *a7 = (char []) { ("bar") }; /* { dg-warning "12:array initialized from parenthesized string constant" } */ diff --git a/gcc/testsuite/gcc.dg/pr53119.c b/gcc/testsuite/gcc.dg/pr53119.c index 044811d833a..93cd3fd8a5e 100644 --- a/gcc/testsuite/gcc.dg/pr53119.c +++ b/gcc/testsuite/gcc.dg/pr53119.c @@ -1,5 +1,4 @@ /* { dg-do compile } */ - /* { dg-options "-Wmissing-braces -Wmissing-field-initializers" } */ struct a { @@ -21,5 +20,3 @@ int main (void) return 0; } - -/* { dg-excess-errors "note" } */ diff --git a/gcc/testsuite/gcc.dg/ucnid-8.c b/gcc/testsuite/gcc.dg/ucnid-8.c index df1f35053d0..da72e2d8e91 100644 --- a/gcc/testsuite/gcc.dg/ucnid-8.c +++ b/gcc/testsuite/gcc.dg/ucnid-8.c @@ -13,4 +13,4 @@ void f (int b) { int \u00e9[b]; } /* { dg-warning "variable length array '\\\\U0 void g (static int \u00e9); /* { dg-error "storage class specified for parameter '\\\\U000000e9'" } */ struct s2 { int \u00e1; } \u00e9 = { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ -/* { dg-warning "near initialization for '\\\\U000000e9\\.\\\\U000000e1'" "UCN diag" { target *-*-* } 15 } */ +/* { dg-message "near initialization for '\\\\U000000e9\\.\\\\U000000e1'" "UCN diag" { target *-*-* } 15 } */ diff --git a/gcc/testsuite/gcc.dg/vla-init-1.c b/gcc/testsuite/gcc.dg/vla-init-1.c index 316bf98bc68..5e20530ab98 100644 --- a/gcc/testsuite/gcc.dg/vla-init-1.c +++ b/gcc/testsuite/gcc.dg/vla-init-1.c @@ -11,5 +11,5 @@ foo (void) { int x[a] = { 1 }; /* { dg-error "variable-sized object may not be initialized" "VLA init" } */ /* { dg-warning "excess elements in array initializer" "excess" { target *-*-* } 12 } */ - /* { dg-warning "near initialization" "near" { target *-*-* } 12 } */ + /* { dg-message "near initialization" "near" { target *-*-* } 12 } */ }