From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2629 invoked by alias); 27 Nov 2009 09:29:20 -0000 Received: (qmail 2612 invoked by uid 22791); 27 Nov 2009 09:29:18 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from vsmtp21.tin.it (HELO vsmtp21.tin.it) (212.216.176.109) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Nov 2009 09:29:10 +0000 Received: from [192.168.0.4] (79.17.189.229) by vsmtp21.tin.it (8.5.113) id 4AC9BFB603600E4D; Fri, 27 Nov 2009 10:29:05 +0100 Message-ID: <4B0F9BDF.60806@oracle.com> Date: Fri, 27 Nov 2009 09:39:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090915 SUSE/3.0b4-3.6 Thunderbird/3.0b4 MIME-Version: 1.0 To: Gabriel Dos Reis CC: "gcc-patches@gcc.gnu.org" , Mark Mitchell Subject: Re: [C++ Patch] Fix PR 35112 References: <4B0F2BD7.6000904@oracle.com> <206fcf960911261742vce0e094qecb4940bc5dade8a@mail.gmail.com> <4B0F2EE3.8070909@oracle.com> <206fcf960911261829k2ee3c5d5g1203325a6c389150@mail.gmail.com> In-Reply-To: <206fcf960911261829k2ee3c5d5g1203325a6c389150@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------030706090004090004030506" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2009-11/txt/msg01517.txt.bz2 This is a multi-part message in MIME format. --------------030706090004090004030506 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 644 Hi again, > Don't pretend I'm that difficult :-) > > Seriously, here is what I meant: in the current print_candidates > the inner for loop i(the one that goes over functions in an > overload set) s repeated twice. So, you can make > that a function of its own, say print_overloaded_functions. > Then print_candidates calls print_overloaded_functions in > the is_overloaded_fn branch, but loops over the list > of overload set in the else branch, calling print_overloaded_functions > with the TREE_VALUE. Does that make sense to you? > Sure. The below is what I have tested on x86_64-linux. Is it ok? Thanks, Paolo. //////////////////// --------------030706090004090004030506 Content-Type: text/plain; name="CL_35112_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL_35112_2" Content-length: 519 /cp 2009-11-27 Paolo Carlini PR c++/35112 * pt.c (print_overloaded_functions): New. (print_candidates): Call the latter. * parser.c (cp_parser_class_name): Do not duplicate the diagnostics after the cp_parser_lookup_name call. /testsuite 2009-11-27 Paolo Carlini PR c++/35112 * g++.dg/parse/crash53.C: New. * g++.dg/parse/error17.C: Adjust, error messages are not duplicated anymore. * g++.dg/template/dtor7.C: Remove xfail-ed dg-bogus directives. --------------030706090004090004030506 Content-Type: text/plain; name="patch_35112_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_35112_2" Content-length: 4094 Index: testsuite/g++.dg/parse/crash53.C =================================================================== --- testsuite/g++.dg/parse/crash53.C (revision 0) +++ testsuite/g++.dg/parse/crash53.C (revision 0) @@ -0,0 +1,13 @@ +// PR c++/35112 + +namespace X { struct A; } // { dg-error "struct X::A" } +namespace Y { struct A; } // { dg-error "struct Y::A" } +namespace Z { struct A; } // { dg-error "struct Z::A" } +namespace W { struct A; } // { dg-error "struct W::A" } + +using namespace X; +using namespace Y; +using namespace Z; +using namespace W; + +A* p; // { dg-error "reference to 'A' is ambiguous|'A' does not name a type" } Index: testsuite/g++.dg/parse/error17.C =================================================================== --- testsuite/g++.dg/parse/error17.C (revision 154697) +++ testsuite/g++.dg/parse/error17.C (working copy) @@ -2,10 +2,8 @@ // PR c++/16965 template struct B { - static int Bar(T); // { dg-error "14:candidates are: " "1" } - // { dg-error "14:with T = int" "2" { target *-*-* } 5 } + static int Bar(T); // { dg-error "14:candidates are: |with T = int" } }; struct D : B, B {}; -int i2 = D::Bar(2); // { dg-error "13:reference to 'Bar' is ambiguous" } -// { dg-error "10:reference to 'Bar' is ambiguous" "2" { target *-*-* } 10 } +int i2 = D::Bar(2); // { dg-error "10:reference to 'Bar' is ambiguous" } Index: testsuite/g++.dg/template/dtor7.C =================================================================== --- testsuite/g++.dg/template/dtor7.C (revision 154697) +++ testsuite/g++.dg/template/dtor7.C (working copy) @@ -1,10 +1,10 @@ // PR c++/40373 // { dg-compile } -struct A; // { dg-bogus "candidates are" "" { xfail *-*-* } } +struct A; namespace { - struct A; // { dg-bogus "struct" "" { xfail *-*-* } } + struct A; } struct B {}; @@ -20,5 +20,3 @@ bar () { foo (B ()); // { dg-bogus "instantiated from here" "" { xfail *-*-* } } } - -// { dg-bogus "is ambiguous" "" { xfail *-*-* } 15 } Index: cp/pt.c =================================================================== --- cp/pt.c (revision 154697) +++ cp/pt.c (working copy) @@ -1646,30 +1646,37 @@ explicit_class_specialization_p (tree type) return !uses_template_parms (CLASSTYPE_TI_ARGS (type)); } +/* Print the list of overloaded FNS in an error message. */ + +static void +print_overloaded_functions (tree fns, const char **str) +{ + tree fn; + for (fn = fns; fn; fn = OVL_NEXT (fn)) + { + if (TREE_CODE (fn) == TREE_LIST) + print_candidates (fn); + else + error ("%s %+#D", *str, OVL_CURRENT (fn)); + *str = " "; + } +} + /* Print the list of candidate FNS in an error message. */ void print_candidates (tree fns) { - tree fn; - tree f; - const char *str = "candidates are:"; if (is_overloaded_fn (fns)) + print_overloaded_functions (fns, &str); + else { - for (f = fns; f; f = OVL_NEXT (f)) - { - error ("%s %+#D", str, OVL_CURRENT (f)); - str = " "; - } + tree fn; + for (fn = fns; fn != NULL_TREE; fn = TREE_CHAIN (fn)) + print_overloaded_functions (TREE_VALUE (fn), &str); } - else for (fn = fns; fn != NULL_TREE; fn = TREE_CHAIN (fn)) - { - for (f = TREE_VALUE (fn); f; f = OVL_NEXT (f)) - error ("%s %+#D", str, OVL_CURRENT (f)); - str = " "; - } } /* Returns the template (one of the functions given by TEMPLATE_ID) Index: cp/parser.c =================================================================== --- cp/parser.c (revision 154697) +++ cp/parser.c (working copy) @@ -15738,14 +15738,8 @@ cp_parser_class_name (cp_parser *parser, identifier_token->location); if (ambiguous_decls) { - error_at (identifier_token->location, - "reference to %qD is ambiguous", identifier); - print_candidates (ambiguous_decls); if (cp_parser_parsing_tentatively (parser)) - { - identifier_token->ambiguous_p = true; - cp_parser_simulate_error (parser); - } + cp_parser_simulate_error (parser); return error_mark_node; } } --------------030706090004090004030506--