From patchwork Mon Jun 9 10:23:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 357380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A6355140080 for ; Mon, 9 Jun 2014 20:24:01 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=jPnOousLkMaSYs20kFqlbDPBHY5kya6EkFmnbohy8nRXaxF8mV CMh8DX0PhBDi8dzqPeBP2gkBtaxz4SnaI1mRcBlmZPYEsh+QR+fCzZhJHh0K/5Nw 1qTX9Ps/H9oJrOixZDgxd/ogcyElEM0ME164zvZiAMbiHXaaKBuXGZlKk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=jtjhA/UALB3wnFUciZT+p5KvnVg=; b=LM7z+c4c3oM0mdO3tiMV WNv3pb1HSECTuNUUM5JiZxBcCx2B6tTiU0j328X02MJkq+8xv32KlkCn2HSkvlJm F1S+tnls0MFPMhCmEE/TQL9hbSaFu7m4IXLx4xPTPUq6fGNk6NX59PV9HgULRNkx wmprWIzWor/YNV0hgxQu/XY= Received: (qmail 903 invoked by alias); 9 Jun 2014 10:23:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 885 invoked by uid 89); 9 Jun 2014 10:23:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jun 2014 10:23:48 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s59ANkPf024843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Jun 2014 06:23:46 -0400 Received: from redhat.com (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s59ANgnD026202 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 9 Jun 2014 06:23:44 -0400 Date: Mon, 9 Jun 2014 12:23:42 +0200 From: Marek Polacek To: GCC Patches Cc: "Joseph S. Myers" Subject: [C PATCH] Use inform for "near initialization for" (PR c/36446) Message-ID: <20140609102342.GA7335@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) It seems that "(near initialization for )" message should be a "note:" message rather than error/warning. This patch changes error_at/warning calls to inform and fixes the testsuite fallout. Tested x86_64-unknown-linux-gnu, ok for trunk? 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. * 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. Marek diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index e4fa0c3..63bd65e 100644 --- gcc/c/c-typeck.c +++ 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 gcc/testsuite/gcc.dg/Wcxx-compat-6.c gcc/testsuite/gcc.dg/Wcxx-compat-6.c index 2b327c4..eee6768 100644 --- gcc/testsuite/gcc.dg/Wcxx-compat-6.c +++ 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 gcc/testsuite/gcc.dg/array-2.c gcc/testsuite/gcc.dg/array-2.c index 497c586..6187500 100644 --- gcc/testsuite/gcc.dg/array-2.c +++ 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 gcc/testsuite/gcc.dg/array-const-2.c gcc/testsuite/gcc.dg/array-const-2.c index f6e2bd5..6f76955 100644 --- gcc/testsuite/gcc.dg/array-const-2.c +++ 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 gcc/testsuite/gcc.dg/array-const-3.c gcc/testsuite/gcc.dg/array-const-3.c index 5bb215c..036b0ea 100644 --- gcc/testsuite/gcc.dg/array-const-3.c +++ 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 gcc/testsuite/gcc.dg/c99-flex-array-7.c gcc/testsuite/gcc.dg/c99-flex-array-7.c index 8966e6c..88018b0 100644 --- gcc/testsuite/gcc.dg/c99-flex-array-7.c +++ 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 gcc/testsuite/gcc.dg/init-bad-1.c gcc/testsuite/gcc.dg/init-bad-1.c index cc808b7..6599de0 100644 --- gcc/testsuite/gcc.dg/init-bad-1.c +++ 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 gcc/testsuite/gcc.dg/init-bad-2.c gcc/testsuite/gcc.dg/init-bad-2.c index 1f0f78b..e151709 100644 --- gcc/testsuite/gcc.dg/init-bad-2.c +++ 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 gcc/testsuite/gcc.dg/init-bad-3.c gcc/testsuite/gcc.dg/init-bad-3.c index 109e65e..82a632a 100644 --- gcc/testsuite/gcc.dg/init-bad-3.c +++ 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 gcc/testsuite/gcc.dg/pedwarn-init.c gcc/testsuite/gcc.dg/pedwarn-init.c index 1261115..e3181d6 100644 --- gcc/testsuite/gcc.dg/pedwarn-init.c +++ 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 gcc/testsuite/gcc.dg/pr53119.c gcc/testsuite/gcc.dg/pr53119.c index 044811d..93cd3fd 100644 --- gcc/testsuite/gcc.dg/pr53119.c +++ 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 gcc/testsuite/gcc.dg/ucnid-8.c gcc/testsuite/gcc.dg/ucnid-8.c index df1f350..da72e2d 100644 --- gcc/testsuite/gcc.dg/ucnid-8.c +++ 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 gcc/testsuite/gcc.dg/vla-init-1.c gcc/testsuite/gcc.dg/vla-init-1.c index 316bf98..5e20530 100644 --- gcc/testsuite/gcc.dg/vla-init-1.c +++ 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 } */ }