From patchwork Tue Jul 9 18:44:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 257852 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 770482C009A for ; Wed, 10 Jul 2013 04:44:57 +1000 (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=JwXNvk7KgnNojg2QztBQ9nJtayUXcLD1t9ELOj+lDsDnBH 7xvoEr7D3Jdo4yk3Yvz/sbguxVJLaXEATR1FYGpU1pdAeLrmaSA4pk5MeDGeNLOh Ny6aXrD5+7LSyXVJ4CAKXKzQwBkEtyjQqys3rq4uLxDz33Ajdt2hXR89OVNu8= 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=A58JWuAyxoh93A/YH6PXjO7FMVE=; b=G/XeJELgKnfDvjIe6JTr RXGxipaBOaO4HO34xy/sxD4yeLxcZoIF3QghOKNJiefBEG6M46yRbop6joOrKgrX jfi+3TKB8kpeWDkmv5/MUBp7TCSFD1bjj+3SDFtTjIGU0Bd2fvPrXbw/beKxDOAt OsXgz/uoPF4/uXwAfRua/Rc= Received: (qmail 22033 invoked by alias); 9 Jul 2013 18:44:50 -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 22024 invoked by uid 89); 9 Jul 2013 18:44:50 -0000 X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_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; Tue, 09 Jul 2013 18:44:49 +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 r69IimEY008825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Jul 2013 14:44:48 -0400 Received: from [10.3.113.19] ([10.3.113.19]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r69Iimu4017421 for ; Tue, 9 Jul 2013 14:44:48 -0400 Message-ID: <51DC5A1F.8020606@redhat.com> Date: Tue, 09 Jul 2013 14:44:47 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/57658 (ICE with decltype of captured variable) X-Virus-Found: No I've recently adjusted finish_id_expression to return the identifier for various uses of outer local variables that aren't captures. This is another. Tested x86_64-pc-linux-gnu, applying to trunk. commit a9fe694d4756d7cd35a35c4fd8f0dd09543ba559 Author: Jason Merrill Date: Mon Jul 8 23:43:23 2013 -0400 PR c++/57658 * semantics.c (finish_id_expression): Return the id for an unevaluated outer variable. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b5bcb00..8da1af4 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3056,15 +3056,15 @@ finish_id_expression (tree id_expression, /* Disallow uses of local variables from containing functions, except within lambda-expressions. */ - if (!outer_var_p (decl) - /* It's not a use (3.2) if we're in an unevaluated context. */ - || cp_unevaluated_operand) - /* OK. */; - else if (TREE_STATIC (decl)) + if (!outer_var_p (decl)) + /* OK */; + else if (TREE_STATIC (decl) + /* It's not a use (3.2) if we're in an unevaluated context. */ + || cp_unevaluated_operand) { if (processing_template_decl) - /* For a use of an outer static var, return the identifier so - that we'll look it up again in the instantiation. */ + /* For a use of an outer static/unevaluated var, return the id + so that we'll look it up again in the instantiation. */ return id_expression; } else diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template12.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template12.C new file mode 100644 index 0000000..635af97 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template12.C @@ -0,0 +1,19 @@ +// PR c++/57568 +// { dg-require-effective-target c++11 } + +template < class T > +struct remove_reference +{ typedef int type; }; +template < class T > +class X +{ + enum Q { }; + bool f () + { + Q a; + [&a]{ + typename remove_reference < decltype (a) >::type t; + }; + } +}; +template class X< int >;