From patchwork Fri Dec 3 16:56:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 74170 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 86C9EB7043 for ; Sat, 4 Dec 2010 03:56:34 +1100 (EST) Received: (qmail 31282 invoked by alias); 3 Dec 2010 16:56:31 -0000 Received: (qmail 31267 invoked by uid 22791); 3 Dec 2010 16:56:30 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Fri, 03 Dec 2010 16:56:25 +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.13.8/8.13.8) with ESMTP id oB3GuOu9027469 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 3 Dec 2010 11:56:24 -0500 Received: from [127.0.0.1] (ovpn-113-75.phx2.redhat.com [10.3.113.75]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB3GuNWJ024888 for ; Fri, 3 Dec 2010 11:56:23 -0500 Message-ID: <4CF92137.4050302@redhat.com> Date: Fri, 03 Dec 2010 11:56:23 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101117 Lightning/1.0b1 Shredder/3.0.11pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/46058 (ICE on explicit scope in template) 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 In templates we keep SCOPE_REFs around even when they aren't dependent so that we can give access control errors at instantiation time. But that means we need to be able to deal with them. Tested x86_64-pc-linux-gnu, applied to trunk. commit dc6397243e8affb028a658b5491c1b5b9d755d0a Author: Jason Merrill Date: Wed Nov 24 18:20:49 2010 -0500 PR c++/46058 * tree.c (lvalue_kind) [SCOPE_REF]: Handle non-dependent case. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5538eea..1a77dc1 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -146,9 +146,12 @@ lvalue_kind (const_tree ref) return clk_ordinary; break; - /* A currently unresolved scope ref. */ + /* A scope ref in a template, left as SCOPE_REF to support later + access checking. */ case SCOPE_REF: - gcc_unreachable (); + gcc_assert (!type_dependent_expression_p (CONST_CAST_TREE(ref))); + return lvalue_kind (TREE_OPERAND (ref, 1)); + case MAX_EXPR: case MIN_EXPR: /* Disallow ? as lvalues if either argument side-effects. */ diff --git a/gcc/testsuite/g++.dg/template/scope4.C b/gcc/testsuite/g++.dg/template/scope4.C new file mode 100644 index 0000000..a4ae074 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/scope4.C @@ -0,0 +1,15 @@ +// PR c++/46058 + +class StringLiterals { +public: + static const char dec[]; +}; + +template +class NoValueCommand : public Base { +public: +}; + +template +class DecBasic : public NoValueCommand { +};