From patchwork Thu Aug 19 17:23:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 62208 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]) by ozlabs.org (Postfix) with SMTP id B4BA5B70E0 for ; Fri, 20 Aug 2010 03:23:12 +1000 (EST) 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 13:23:01 -0400 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 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 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. 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); +