From patchwork Wed Mar 27 14:41:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 231722 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id DE6E52C064F for ; Thu, 28 Mar 2013 01:42:27 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=hPoOy5Z8pKzZ+3HdWRhARmUEzb1aORqIJzscuFjfPDlaYV pN34sgp+utX98abWPIuuW4wbNwlUYdHgDKSP3pSwBVsLD7b/QXbFjLXsCN5W+lTm SpFpq3X7jnOPZt7/d+9XFvr/pOW2XIwY6yqP4gZFJUSOp0i17s9M3sohPmPAs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=ipj5L5jN+X66DBDK/iD6aBT7mY4=; b=MIXBtvNXmMszgEu/UNq0 973CR1U7oV4gEX9eQte7xbalZ6kJ01I5zcFVQ7AdOMSge/eC45hi1vfUd5drHwHm fF8yUfPfbBNJfJpF6u/ovbGY2vlbVq0m5IZGvOI1R6yA0IDTgwIomkQrPctU4xbM pHw+N8Ie1fy1stlQRl6U+PQ= Received: (qmail 13535 invoked by alias); 27 Mar 2013 14:42:11 -0000 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 Received: (qmail 13513 invoked by uid 89); 27 Mar 2013 14:42:02 -0000 X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 27 Mar 2013 14:41:59 +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 r2REfwu0025947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Mar 2013 10:41:58 -0400 Received: from [10.3.113.57] (ovpn-113-57.phx2.redhat.com [10.3.113.57]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2REfswc032676 for ; Wed, 27 Mar 2013 10:41:55 -0400 Message-ID: <51530532.7040707@redhat.com> Date: Wed, 27 Mar 2013 10:41:54 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Thunderbird/21.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/56749 (wrongly treating scoped enums as dependent) X-Virus-Found: No My change to treat SCOPE_REFs in a template as instantiation-dependent due to access issues incorrectly affected scoped enums; we don't need to worry about access for them, since there are no access-specifiers in an enum. Tested x86_64-pc-linux-gnu, applying to trunk and 4.8. commit 279da5952b411af833810a644ed650a566515a5e Author: Jason Merrill Date: Wed Mar 27 09:35:35 2013 -0400 PR c++/56749 * semantics.c (finish_qualified_id_expr): Return early for enum scope. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fd77725..72b884e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1762,6 +1762,10 @@ finish_qualified_id_expr (tree qualifying_class, return expr; } + /* No need to check access within an enum. */ + if (TREE_CODE (qualifying_class) == ENUMERAL_TYPE) + return expr; + /* Within the scope of a class, turn references to non-static members into expression of the form "this->...". */ if (template_arg_p) diff --git a/gcc/testsuite/g++.dg/cpp0x/enum24.C b/gcc/testsuite/g++.dg/cpp0x/enum24.C new file mode 100644 index 0000000..6099656 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum24.C @@ -0,0 +1,57 @@ +// PR c++/56749 +// { dg-require-effective-target c++11 } + +enum normal_enum +{ + not_scoped1, + not_scoped2 +}; + +enum class scoped_enum +{ + scoped1, + scoped2 +}; + +template +class A +{ +public: + template + void fun () + { + } +}; + +template +class B +{ +public: + template + void fun () + { + } +}; + + +template +void tfun () +{ + A<> a; + a.fun(); //<------------ THIS IS FINE + + B<> b_defaulted; + B b_explicited; + + b_defaulted.fun(); //<------------ UNEXPECTED: THIS FAILS + b_defaulted.template fun(); //<------------ THIS IS FINE + + b_explicited.fun(); //<------------ UNEXPECTED: THIS FAILS + b_explicited.template fun();//<------------ THIS IS FINE +} + +int main(int argc, char const *argv[]) +{ + tfun(); + return 0; +}