From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20913 invoked by alias); 19 Aug 2010 17:23:09 -0000 Received: (qmail 20895 invoked by uid 22791); 19 Aug 2010 17:23:08 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 Aug 2010 17:23:04 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7JHN2pf008209 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 Aug 2010 13:23:02 -0400 Received: from [IPv6:::1] (ovpn-113-45.phx2.redhat.com [10.3.113.45]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7JHN2pQ016061 for ; Thu, 19 Aug 2010 13:23:02 -0400 Message-ID: <4C6D6875.7090301@redhat.com> Date: Thu, 19 Aug 2010 17:32:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100814 Lightning/1.0b1 Shredder/3.0.7pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH to overload resolution in synthesized member functions Content-Type: multipart/mixed; boundary="------------040708010101050205010409" 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: 2010-08/txt/msg01479.txt.bz2 This is a multi-part message in MIME format. --------------040708010101050205010409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 311 The overload resolution hack I made to fix c++/44909 is coming to seem like the right way to fix this issue in the standard; this patch refines it a bit so that overload resolution is the same in determining the signature and in actually defining the function. Tested x86_64-pc-linux-gnu, applied to trunk. --------------040708010101050205010409 Content-Type: text/x-patch; name="synth-overload.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="synth-overload.patch" Content-length: 2116 commit 96b87db748e5800d276887ae90dc85634c5d9bbc Author: Jason Merrill Date: Wed Aug 18 18:20:12 2010 -0400 * call.c (reference_related_p): Check for error_mark_node. (add_function_candidate): Check it instead of same_type_ignoring_top_level_qualifiers_p. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 71297ec..adcf984 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -999,6 +999,9 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, bool reference_related_p (tree t1, tree t2) { + if (t1 == error_mark_node || t2 == error_mark_node) + return false; + t1 = TYPE_MAIN_VARIANT (t1); t2 = TYPE_MAIN_VARIANT (t2); @@ -1598,8 +1601,10 @@ add_function_candidate (struct z_candidate **candidates, /* Kludge: When looking for a function from a subobject while generating an implicit copy/move constructor/operator=, don't consider anything - that takes (a reference to) a different type. See c++/44909. */ - else if (flags & LOOKUP_SPECULATIVE) + that takes (a reference to) an unrelated type. See c++/44909. */ + else if ((flags & LOOKUP_SPECULATIVE) + || (current_function_decl + && DECL_DEFAULTED_FN (current_function_decl))) { if (DECL_CONSTRUCTOR_P (fn)) i = 1; @@ -1611,8 +1616,8 @@ add_function_candidate (struct z_candidate **candidates, if (i && len == i) { parmnode = chain_index (i-1, parmlist); - if (!(same_type_ignoring_top_level_qualifiers_p - (non_reference (TREE_VALUE (parmnode)), ctype))) + if (!reference_related_p (non_reference (TREE_VALUE (parmnode)), + ctype)) viable = 0; } } diff --git a/gcc/testsuite/g++.dg/init/synth3.C b/gcc/testsuite/g++.dg/init/synth3.C new file mode 100644 index 0000000..d656ddb --- /dev/null +++ b/gcc/testsuite/g++.dg/init/synth3.C @@ -0,0 +1,21 @@ +// Test that synthesizing the C copy constructor doesn't require B to +// be complete. + +template +struct B +{ + typename T::NT nt; +}; + +struct A +{ + A (); + A (const A&); + A (const B&); +}; + +struct C: A { }; + +C c; +C c2(c); + --------------040708010101050205010409--