From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15386 invoked by alias); 10 Nov 2014 04:49:40 -0000 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 Received: (qmail 15372 invoked by uid 89); 10 Nov 2014 04:49:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 10 Nov 2014 04:49:38 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAA4nbpI031520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sun, 9 Nov 2014 23:49:37 -0500 Received: from [10.10.116.25] ([10.10.116.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAA4nb5a002667 for ; Sun, 9 Nov 2014 23:49:37 -0500 Message-ID: <546043DF.20302@redhat.com> Date: Mon, 10 Nov 2014 04:49:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for core DR 2007 Content-Type: multipart/mixed; boundary="------------060206090808060607080200" X-SW-Source: 2014-11/txt/msg00762.txt.bz2 This is a multi-part message in MIME format. --------------060206090808060607080200 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 171 DR 2007 points out that there's no need to do argument-dependent lookup for operator=, which has to be a member function. Tested x86_64-pc-linux-gnu, applying to trunk. --------------060206090808060607080200 Content-Type: text/x-patch; name="dr2007.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dr2007.patch" Content-length: 2139 commit 7601c0b8fb5d7093479f5587057f049bdc6cb622 Author: Jason Merrill Date: Sat Nov 8 09:32:15 2014 -0600 DR 2007 * call.c (build_new_op_1): Don't do non-class lookup for =, -> or []. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 31864e9..bf191ca 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5309,6 +5309,7 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, arg1 = prep_operand (arg1); + bool memonly = false; switch (code) { case NEW_EXPR: @@ -5340,6 +5341,16 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, code_orig_arg1 = TREE_CODE (TREE_TYPE (arg1)); code_orig_arg2 = TREE_CODE (TREE_TYPE (arg2)); break; + + /* =, ->, [], () must be non-static member functions. */ + case MODIFY_EXPR: + if (code2 != NOP_EXPR) + break; + case COMPONENT_REF: + case ARRAY_REF: + memonly = true; + break; + default: break; } @@ -5369,10 +5380,12 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, /* Add namespace-scope operators to the list of functions to consider. */ - add_candidates (lookup_function_nonclass (fnname, arglist, /*block_p=*/true), - NULL_TREE, arglist, NULL_TREE, - NULL_TREE, false, NULL_TREE, NULL_TREE, - flags, &candidates, complain); + if (!memonly) + add_candidates (lookup_function_nonclass (fnname, arglist, + /*block_p=*/true), + NULL_TREE, arglist, NULL_TREE, + NULL_TREE, false, NULL_TREE, NULL_TREE, + flags, &candidates, complain); args[0] = arg1; args[1] = arg2; diff --git a/gcc/testsuite/g++.dg/template/operator14.C b/gcc/testsuite/g++.dg/template/operator14.C new file mode 100644 index 0000000..6267dbb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/operator14.C @@ -0,0 +1,7 @@ +// DR 2007 +// We shouldn't instantiate A to lookup operator=, since operator= +// must be a non-static member function. + +template struct A { typename T::error e; }; +template struct B { }; +B > b1, &b2 = (b1 = b1); --------------060206090808060607080200--