From patchwork Wed Apr 27 05:15:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 92982 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 B6A411007D7 for ; Wed, 27 Apr 2011 15:15:35 +1000 (EST) Received: (qmail 7540 invoked by alias); 27 Apr 2011 05:15:32 -0000 Received: (qmail 7522 invoked by uid 22791); 27 Apr 2011 05:15:31 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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; Wed, 27 Apr 2011 05:15:12 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3R5FBrN008661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Apr 2011 01:15:11 -0400 Received: from [127.0.0.1] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3R5FBKL003829 for ; Wed, 27 Apr 2011 01:15:11 -0400 Message-ID: <4DB7A65E.5000706@redhat.com> Date: Wed, 27 Apr 2011 01:15:10 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/42687 (arg-dependent lookup regression) 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 When we fixed using explicit scope to suppress virtual calling, it broke using parentheses to suppress argument-dependent lookup. Fixed thus. Tested x86_64-pc-linux-gnu, applied to trunk, 4.4, 4.5 and 4.6. commit 2bc3ed125eab1075ea18c7c80e5ab908130861fd Author: Jason Merrill Date: Tue Apr 26 21:39:34 2011 -0400 PR c++/42687 * parser.c (cp_parser_primary_expression): Set *idk to CP_ID_KIND_NONE for a parenthesized identifier. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6da285e..68ce052 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3437,6 +3437,12 @@ cp_parser_primary_expression (cp_parser *parser, `&A::B' might be a pointer-to-member, but `&(A::B)' is not. */ finish_parenthesized_expr (expr); + /* DR 705: Wrapping an unqualified name in parentheses + suppresses arg-dependent lookup. We want to pass back + CP_ID_KIND_QUALIFIED for suppressing vtable lookup + (c++/37862), but none of the others. */ + if (*idk != CP_ID_KIND_QUALIFIED) + *idk = CP_ID_KIND_NONE; } /* The `>' token might be the end of a template-id or template-parameter-list now. */ diff --git a/gcc/testsuite/g++.dg/lookup/koenig13.C b/gcc/testsuite/g++.dg/lookup/koenig13.C new file mode 100644 index 0000000..625a181 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/koenig13.C @@ -0,0 +1,16 @@ +// PR c++/42687 +// DR 705 + +namespace N +{ + struct S { }; + void f(const S &) { } +} + +void f(const N::S &) { } + +int main() +{ + N::S v; + (f)(v); // no ambiguity: ADL is prevented with (), only ::f is considered +}