From patchwork Wed May 15 17:10:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 244145 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1A2DE2C00A8 for ; Thu, 16 May 2013 03:11:14 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=hghOW5GKvQ9jP7ct79LWv54UQDETGcEPy/an/BwuAdWbUf fBWMJvIs8qKScfwfIuBL8EJ9yIZcbstTbOCDQgROzjZP5jXFga0RWtAwJePA2pIX pSAPLTwbRUKElb0CCd0fQYDSW0Z9elrR4HPMG7nnDLdaL/5uTBykM+AiZmSOI= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=iN9CxSrhCLOl71wXxpdIJvWFHB4=; b=Azr/50zDDR6Zo6q6FwGf VcwxJo782bBqD6xjBUUFifq7WV0+hxypd2kYv+z/a2s3LMHyrq0QZMUpLDFgbMq2 +T86qi1z0LRfsjG1SrPYk495paJAmptGDUX3KlJkeHUAIZnqSULWMo+uJPWVQIUP wnbK6/Bi02NTt0kYZEB36o8= Received: (qmail 22528 invoked by alias); 15 May 2013 17:11:07 -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 22484 invoked by uid 89); 15 May 2013 17:11:01 -0000 X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 15 May 2013 17:10:59 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4FHAuXR023694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 15 May 2013 17:10:56 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4FHAuqG008910 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 15 May 2013 17:10:57 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4FHAu5m024681; Wed, 15 May 2013 17:10:56 GMT Received: from poldo4.casa (/79.43.213.246) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 15 May 2013 10:10:56 -0700 Message-ID: <5193C19D.6010005@oracle.com> Date: Wed, 15 May 2013 19:10:53 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" , Jason Merrill Subject: [C++ Patch] Use inform more in pushdecl_maybe_friend_1 X-Virus-Found: No Hi, while working on the last patch I noticed a few more cases of warning_at and permerror pairs where it makes sense to use inform. Tested x86_64-linux. Thanks, Paolo. /////////////////////////// /cp 2013-05-15 Paolo Carlini * name-lookup.c (pushdecl_maybe_friend_1): Replace pairs of warning_at and permerror to warning_at / inform and permerror / inform, respectively. /testsuite 2013-05-15 Paolo Carlini * g++.dg/cpp0x/lambda/lambda-shadow1.C: Replace dg-warnings with dg-messages. * g++.dg/warn/Wshadow-1.C: Likewise. * g++.dg/warn/Wshadow-6.C: Likewise. * g++.dg/warn/Wshadow-7.C: Likewise. Index: cp/name-lookup.c =================================================================== --- cp/name-lookup.c (revision 198939) +++ cp/name-lookup.c (working copy) @@ -943,8 +943,10 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) && TREE_CODE (decl) == TREE_CODE (x) && !same_type_p (TREE_TYPE (x), TREE_TYPE (decl))) { - permerror (input_location, "type mismatch with previous external decl of %q#D", x); - permerror (input_location, "previous external decl of %q+#D", decl); + if (permerror (input_location, "type mismatch with previous " + "external decl of %q#D", x)) + inform (input_location, "previous external decl of %q+#D", + decl); } } @@ -1161,19 +1163,23 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) if (warn_shadow && !nowarn) { + bool warned; + if (TREE_CODE (oldlocal) == PARM_DECL) - warning_at (input_location, OPT_Wshadow, + warned = warning_at (input_location, OPT_Wshadow, "declaration of %q#D shadows a parameter", x); else if (is_capture_proxy (oldlocal)) - warning_at (input_location, OPT_Wshadow, + warned = warning_at (input_location, OPT_Wshadow, "declaration of %qD shadows a lambda capture", x); else - warning_at (input_location, OPT_Wshadow, + warned = warning_at (input_location, OPT_Wshadow, "declaration of %qD shadows a previous local", x); - warning_at (DECL_SOURCE_LOCATION (oldlocal), OPT_Wshadow, - "shadowed declaration is here"); + + if (warned) + inform (DECL_SOURCE_LOCATION (oldlocal), + "shadowed declaration is here"); } } @@ -1213,10 +1219,11 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) || TREE_CODE (x) == TYPE_DECL)))) /* XXX shadow warnings in outer-more namespaces */ { - warning_at (input_location, OPT_Wshadow, - "declaration of %qD shadows a global declaration", x); - warning_at (DECL_SOURCE_LOCATION (oldglobal), OPT_Wshadow, - "shadowed declaration is here"); + if (warning_at (input_location, OPT_Wshadow, + "declaration of %qD shadows a " + "global declaration", x)) + inform (DECL_SOURCE_LOCATION (oldglobal), + "shadowed declaration is here"); } } } Index: testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C (revision 198936) +++ testsuite/g++.dg/cpp0x/lambda/lambda-shadow1.C (working copy) @@ -2,7 +2,7 @@ // { dg-options "-std=c++11 -Wshadow" } int main() { - int x = 1; // { dg-warning "shadowed" } + int x = 1; // { dg-message "shadowed" } auto const lambda = [](int x) { // { dg-warning "shadows" } return x; }; Index: testsuite/g++.dg/warn/Wshadow-1.C =================================================================== --- testsuite/g++.dg/warn/Wshadow-1.C (revision 198936) +++ testsuite/g++.dg/warn/Wshadow-1.C (working copy) @@ -18,8 +18,8 @@ struct status // { dg-bogus "shadowed declaratio } }; -int decl1; // { dg-warning "shadowed declaration" } -int decl2; // { dg-warning "shadowed declaration" } +int decl1; // { dg-message "shadowed declaration" } +int decl2; // { dg-message "shadowed declaration" } void foo (struct status &status,// { dg-bogus "shadows a global decl" } double decl1) // { dg-warning "shadows a global decl" } { @@ -34,7 +34,7 @@ void status::foo2 () { int member; // { dg-warning "shadows a member" } int decl2; // { dg-warning "shadows a global decl" } - int local; // { dg-warning "shadowed declaration" } + int local; // { dg-message "shadowed declaration" } { int local; // { dg-warning "shadows a previous local" } } Index: testsuite/g++.dg/warn/Wshadow-6.C =================================================================== --- testsuite/g++.dg/warn/Wshadow-6.C (revision 198936) +++ testsuite/g++.dg/warn/Wshadow-6.C (working copy) @@ -4,10 +4,10 @@ // { dg-options "-std=c++0x -Wshadow" } struct S {}; -int f1(int x) // { dg-warning "shadowed declaration" } +int f1(int x) // { dg-message "shadowed declaration" } { int t = 0; - int m = 0; // { dg-warning "shadowed declaration" } + int m = 0; // { dg-message "shadowed declaration" } [&t] (int x) { // { dg-warning "shadows a parameter" } int m = 1; // { dg-warning "shadows a previous local" } t = t + x + m; @@ -18,9 +18,9 @@ struct S {}; void f2(struct S i, int j) { struct A { struct S x; - void g(struct S i) { // { dg-warning "shadowed declaration" } + void g(struct S i) { // { dg-message "shadowed declaration" } struct S x; // { dg-warning "shadows a member of" } - struct S y; // { dg-warning "shadowed declaration" } + struct S y; // { dg-message "shadowed declaration" } int t; [&t](struct S i){ // { dg-warning "shadows a parameter" } int j = 1; // { dg-bogus "shadows" } @@ -33,7 +33,7 @@ void f2(struct S i, int j) { void f3(int i) { [=]{ - int j = i; // { dg-warning "shadowed declaration" } + int j = i; // { dg-message "shadowed declaration" } int i; // { dg-warning "shadows a lambda capture" } i = 1; }; @@ -42,7 +42,7 @@ void f3(int i) { template void f4(int i) { [=]{ - int j = i; // { dg-warning "shadowed declaration" } + int j = i; // { dg-message "shadowed declaration" } int i; // { dg-warning "shadows a lambda capture" } i = 1; }; Index: testsuite/g++.dg/warn/Wshadow-7.C =================================================================== --- testsuite/g++.dg/warn/Wshadow-7.C (revision 198936) +++ testsuite/g++.dg/warn/Wshadow-7.C (working copy) @@ -1,18 +1,18 @@ // PR c++/44128 // { dg-options "-Wshadow" } -typedef long My_ssize_t; // { dg-warning "shadowed declaration" } -typedef int Foo; // { dg-warning "shadowed declaration" } +typedef long My_ssize_t; // { dg-message "shadowed declaration" } +typedef int Foo; // { dg-message "shadowed declaration" } struct Bar1 { // { dg-bogus "shadowed declaration" } int a; }; -struct Bar2 { // { dg-warning "shadowed declaration" } +struct Bar2 { // { dg-message "shadowed declaration" } int a; }; void func() { typedef int My_ssize_t; // { dg-warning "shadows a global" } - typedef char My_Num; // { dg-warning "shadowed declaration" } + typedef char My_Num; // { dg-message "shadowed declaration" } { typedef short My_Num; // { dg-warning "shadows a previous local" } } @@ -21,7 +21,7 @@ void func() { struct Bar2 { // { dg-warning "shadows a global" } int a; }; - struct Bar3 { // { dg-warning "shadowed declaration" } + struct Bar3 { // { dg-message "shadowed declaration" } int a; }; struct Bar4 { // { dg-bogus "shadowed declaration" }