From patchwork Fri May 19 16:13:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 764779 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 3wTtQf6PcRz9s0m for ; Sat, 20 May 2017 02:13:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="nrI4EBK1"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=FSDWB81XQ+6TRxqnZIKRp/4iRCej5s8X0MdiOsiq3ajtaT3eov NSj0uMjGKQtTvMsMvwX6O7/xgzlIttK5gQSlB2m0q1dwgZNFSMhLk1wb4rHpfi7X NFcZ53TBmmcJG4r2xXuKov1Ym7VSlnBxn6+TWPUGXSEU/Jn7+IrbosFg8= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=WVFJlQQnX9PSGS+FB/hFW0JnueA=; b=nrI4EBK1Y+CcUSoVrmb7 je68iLcSKmm2IxvNwaiNwZQT70wA+mro8h/CEOHS7R+ueZzhk4yZGTyaRkan7aMH SjbB55rkeo12BS+hLhhaddCMP6MeN9xBzg8EnhqYA6Xhr83jS28SmWNXWTNya5Wl C+AvepVPGQ1yt+pSvJ8wGbA= Received: (qmail 45854 invoked by alias); 19 May 2017 16:13:26 -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 45822 invoked by uid 89); 19 May 2017 16:13:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=benjamin, talks, brendan X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 May 2017 16:13:21 +0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v4JGDMRR030605 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 19 May 2017 16:13:22 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v4JGDLhA025144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 May 2017 16:13:22 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v4JGDJPq021824 for ; Fri, 19 May 2017 16:13:20 GMT Received: from [192.168.1.4] (/79.46.216.225) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 19 May 2017 09:13:19 -0700 To: "gcc-patches@gcc.gnu.org" From: Paolo Carlini Subject: [C++ Patch] Replace a few more error + error with error + inform Message-ID: <8407427e-d71a-e7ab-80b4-c43241044918@oracle.com> Date: Fri, 19 May 2017 18:13:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, while looking into some bugs (eg, c++/71464) I noticed a few more of those consecutive errors, which I propose to adjust per the below patchlet. The second case in add_method is a bit tricky because in principle we'd really like to be more specific (eg, clang talks about constructors which cannot be redeclared, member functions which cannot be redeclared and many more) and avoid verbose diagnostic, but in the below I only try to avoid emitting error + error... Tested x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2017-05-19 Paolo Carlini * class.c (add_method): Change pair of errors to error + inform. (handle_using_decl): Likewise. /testsuite 2017-05-19 Paolo Carlini * g++.dg/cpp0x/inh-ctor3.C: Adjust for dg-message vs dg-error. * g++.dg/diagnostic/variadic1.C: Likewise. * g++.dg/gomp/udr-3.C: Likewise. * g++.dg/overload/error1.C: Likewise. * g++.dg/overload/error2.C: Likewise. * g++.dg/template/duplicate1.C: Likewise. * g++.old-deja/g++.benjamin/warn02.C: Likewise. * g++.old-deja/g++.brendan/arm2.C: Likewise. * g++.old-deja/g++.other/redecl2.C: Likewise. * g++.old-deja/g++.other/redecl4.C: Likewise. * g++.old-deja/g++.pt/memtemp78.C: Likewise. Index: cp/class.c =================================================================== --- cp/class.c (revision 248245) +++ cp/class.c (working copy) @@ -1212,10 +1212,11 @@ add_method (tree type, tree method, bool via_using continue; } error_at (DECL_SOURCE_LOCATION (method), - "%q#D", method); - error_at (DECL_SOURCE_LOCATION (fn), - "conflicts with version inherited from %qT", - basef); + "%q#D conflicts with version inherited from %qT", + method, basef); + inform (DECL_SOURCE_LOCATION (fn), + "version inherited from %qT declared here", + basef); } /* Otherwise defer to the other function. */ return false; @@ -1233,8 +1234,10 @@ add_method (tree type, tree method, bool via_using } else { - error ("%q+#D cannot be overloaded", method); - error ("with %q+#D", fn); + error_at (DECL_SOURCE_LOCATION (method), + "%q#D cannot be overloaded with %q#D", method, fn); + inform (DECL_SOURCE_LOCATION (fn), + "previous declaration %q#D", fn); return false; } } @@ -1366,16 +1369,21 @@ handle_using_decl (tree using_decl, tree t) the same name already present in the current class. */; else { - error ("%q+D invalid in %q#T", using_decl, t); - error (" because of local method %q+#D with same name", - old_value); + error_at (DECL_SOURCE_LOCATION (using_decl), "%qD invalid in %q#T " + "because of local method %q#D with same name", + using_decl, t, old_value); + inform (DECL_SOURCE_LOCATION (old_value), + "local method %q#D declared here", old_value); return; } } else if (!DECL_ARTIFICIAL (old_value)) { - error ("%q+D invalid in %q#T", using_decl, t); - error (" because of local member %q+#D with same name", old_value); + error_at (DECL_SOURCE_LOCATION (using_decl), "%qD invalid in %q#T " + "because of local member %q#D with same name", + using_decl, t, old_value); + inform (DECL_SOURCE_LOCATION (old_value), + "local member %q#D declared here", old_value); return; } Index: testsuite/g++.dg/cpp0x/inh-ctor3.C =================================================================== --- testsuite/g++.dg/cpp0x/inh-ctor3.C (revision 248244) +++ testsuite/g++.dg/cpp0x/inh-ctor3.C (working copy) @@ -8,7 +8,7 @@ struct B2 { B2(int); }; struct D1 : B1, B2 { - using B1::B1; // { dg-error "inherited" } + using B1::B1; // { dg-message "declared" } using B2::B2; // { dg-error "inherited" } }; // ill-formed: attempts to declare D1(int) twice struct D2 : B1, B2 { Index: testsuite/g++.dg/diagnostic/variadic1.C =================================================================== --- testsuite/g++.dg/diagnostic/variadic1.C (revision 248244) +++ testsuite/g++.dg/diagnostic/variadic1.C (working copy) @@ -4,6 +4,6 @@ template struct B { }; template struct A { - B f(); // { dg-error "sizeof\\.\\.\\." } + B f(); // { dg-message "sizeof\\.\\.\\." } B<42> f(); // { dg-error "cannot be overloaded" } }; Index: testsuite/g++.dg/gomp/udr-3.C =================================================================== --- testsuite/g++.dg/gomp/udr-3.C (revision 248244) +++ testsuite/g++.dg/gomp/udr-3.C (working copy) @@ -77,7 +77,7 @@ namespace N2 { struct U { - #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s) // { dg-error "with" } + #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s) // { dg-message "previous" } #pragma omp declare reduction (bar: S: omp_out.s += omp_in.s) // { dg-error "cannot be overloaded" } }; } @@ -109,9 +109,9 @@ namespace N4 struct U { #pragma omp declare reduction (bar: T: omp_out.t += omp_in.t) - #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s) // { dg-error "with" } + #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s) // { dg-message "previous" } #pragma omp declare reduction (bar: S: omp_out.s += omp_in.s) // { dg-error "cannot be overloaded" } - #pragma omp declare reduction (bar: long: omp_out += omp_in) // { dg-error "with" } + #pragma omp declare reduction (bar: long: omp_out += omp_in) // { dg-message "previous" } #pragma omp declare reduction (bar: long int: omp_out += omp_in) // { dg-error "cannot be overloaded" } #pragma omp declare reduction (bar: short unsigned: omp_out += omp_in) #pragma omp declare reduction (bar: short int: omp_out += omp_in) @@ -132,7 +132,7 @@ namespace N5 template struct U { - #pragma omp declare reduction (bar: T: omp_out.s *= omp_in.s) // { dg-error "with" } + #pragma omp declare reduction (bar: T: omp_out.s *= omp_in.s) // { dg-message "previous" } #pragma omp declare reduction (bar: T: omp_out.s += omp_in.s) // { dg-error "cannot be overloaded" } }; U u; @@ -159,9 +159,9 @@ namespace N6 { typedef V V2; #pragma omp declare reduction (bar: T: omp_out.t += omp_in.t) - #pragma omp declare reduction (bar: V: omp_out.s *= omp_in.s) // { dg-error "with" } + #pragma omp declare reduction (bar: V: omp_out.s *= omp_in.s) // { dg-message "previous" } #pragma omp declare reduction (bar: V2: omp_out.s += omp_in.s) // { dg-error "cannot be overloaded" } - #pragma omp declare reduction (bar: long: omp_out += omp_in) // { dg-error "with" } + #pragma omp declare reduction (bar: long: omp_out += omp_in) // { dg-message "previous" } #pragma omp declare reduction (bar: long int: omp_out += omp_in) // { dg-error "cannot be overloaded" } #pragma omp declare reduction (bar: short unsigned: omp_out += omp_in) #pragma omp declare reduction (bar: short int: omp_out += omp_in) Index: testsuite/g++.dg/overload/error1.C =================================================================== --- testsuite/g++.dg/overload/error1.C (revision 248244) +++ testsuite/g++.dg/overload/error1.C (working copy) @@ -2,6 +2,6 @@ struct S { - void f () {} // { dg-error "with" } + void f () {} // { dg-message "previous" } int f () { return 0; } // { dg-error "overloaded" } }; Index: testsuite/g++.dg/overload/error2.C =================================================================== --- testsuite/g++.dg/overload/error2.C (revision 248244) +++ testsuite/g++.dg/overload/error2.C (working copy) @@ -6,6 +6,6 @@ struct A { - void foo(); // { dg-error "with" } + void foo(); // { dg-message "previous" } virtual void foo(); // { dg-error "cannot be overloaded" } }; Index: testsuite/g++.dg/template/duplicate1.C =================================================================== --- testsuite/g++.dg/template/duplicate1.C (revision 248244) +++ testsuite/g++.dg/template/duplicate1.C (working copy) @@ -2,6 +2,6 @@ template struct A { - ~A() {} // { dg-error "with" } + ~A() {} // { dg-message "previous" } ~A() {} // { dg-error "cannot be overloaded" } }; Index: testsuite/g++.old-deja/g++.benjamin/warn02.C =================================================================== --- testsuite/g++.old-deja/g++.benjamin/warn02.C (revision 248244) +++ testsuite/g++.old-deja/g++.benjamin/warn02.C (working copy) @@ -31,7 +31,7 @@ class C class D { public: - int foo2() {return b;} // { dg-error "with" } + int foo2() {return b;} // { dg-message "previous" } int foo2() {return b;} // { dg-error "overloaded" } int b; }; @@ -39,7 +39,7 @@ class D class E { public: - int foo2(); // { dg-error "with" } + int foo2(); // { dg-message "previous" } int foo2(); // { dg-error "overloaded" } int b; }; Index: testsuite/g++.old-deja/g++.brendan/arm2.C =================================================================== --- testsuite/g++.old-deja/g++.brendan/arm2.C (revision 248244) +++ testsuite/g++.old-deja/g++.brendan/arm2.C (working copy) @@ -8,12 +8,12 @@ class X { public: - int foo(); // { dg-error "with" } + int foo(); // { dg-message "previous" } static int foo(); // error: redeclaration// { dg-error "overloaded" } .* }; class Y { public: - static int foo(); // { dg-error "with" } + static int foo(); // { dg-message "previous" } int foo(); // error: redeclaration// { dg-error "overloaded" } .* }; Index: testsuite/g++.old-deja/g++.other/redecl2.C =================================================================== --- testsuite/g++.old-deja/g++.other/redecl2.C (revision 248244) +++ testsuite/g++.old-deja/g++.other/redecl2.C (working copy) @@ -1,9 +1,9 @@ // { dg-do assemble } struct S { - S(int); // { dg-error "with" } + S(int); // { dg-message "previous" } S(int); // { dg-error "overloaded" } already declared - ~S();// { dg-error "with" } + ~S();// { dg-message "previous" } ~S(); // { dg-error "overloaded" } already declared }; Index: testsuite/g++.old-deja/g++.other/redecl4.C =================================================================== --- testsuite/g++.old-deja/g++.other/redecl4.C (revision 248244) +++ testsuite/g++.old-deja/g++.other/redecl4.C (working copy) @@ -1,7 +1,7 @@ // { dg-do assemble } int main() { struct A { - void f(); // { dg-error "with" } already declared + void f(); // { dg-message "previous" } already declared void f(); // { dg-error "overloaded" } already declared }; } Index: testsuite/g++.old-deja/g++.pt/memtemp78.C =================================================================== --- testsuite/g++.old-deja/g++.pt/memtemp78.C (revision 248244) +++ testsuite/g++.old-deja/g++.pt/memtemp78.C (working copy) @@ -23,7 +23,7 @@ template struct B; struct C { template - void f() {} // { dg-error "with" } redeclaration + void f() {} // { dg-message "previous" } redeclaration template void f() {} // { dg-error "overloaded" } redeclaration @@ -42,7 +42,7 @@ template struct D; template struct D2 { - void f(T); // { dg-error "with" } redeclaration + void f(T); // { dg-message "previous" } redeclaration void f(U); // { dg-error "overloaded" } redeclaration }; @@ -50,7 +50,7 @@ template struct D2; struct E { - void f(); // { dg-error "with" } redeclaration + void f(); // { dg-message "previous" } redeclaration void f(); // { dg-error "overloaded" } redeclaration };