From patchwork Sun Mar 17 01:42:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 228262 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 2C95E2C00AA for ; Sun, 17 Mar 2013 12:43:15 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1364089397; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=RaU8dmH E47otPFfyJRd9XGcPuOE=; b=NfuPQnzeE/XEM9Psy43PPYRK5JUwZqyOa4LVNNo e1FryUANgjGt6jRQtPeTjUi3+Vuyia/eMkTyl5ywt6WF+M+mV2h8J1w6kV8jgMrq qMuA6N9EXvCuMGKqw0P6nC5yo5JN8wlK4/gZ/C9jq7ebky/7+BFdUxWp8Q1z2DER dDpc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=aXhsqt0w4zi00Efr/n9pniaysGzBC+NV2PgQD+oGFi+Aj+OEwxttzc1RdX3qnB IezYo3akbia6Qxlav/hWKsisMMFJFnV1HQk5WBuUA4xItvTF0V+OTYiReieHL1Ih yFAohiZ0lLbbv090XzNLNkY0Km24O7/jhGlnAAYMLmPVM=; Received: (qmail 7429 invoked by alias); 17 Mar 2013 01:43:09 -0000 Received: (qmail 7290 invoked by uid 22791); 17 Mar 2013 01:43:07 -0000 X-SWARE-Spam-Status: No, hits=-7.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Sun, 17 Mar 2013 01:43:01 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2H1h0WJ027524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 16 Mar 2013 21:43:00 -0400 Received: from [10.3.113.56] (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2H1gwvO028017 for ; Sat, 16 Mar 2013 21:43:00 -0400 Message-ID: <51451FA2.3050802@redhat.com> Date: Sat, 16 Mar 2013 21:42:58 -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++/56039 (ICE with lambda in template argument) 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 A lambda in a template argument is ill-formed, but we shouldn't ICE. Tested x86_64-pc-linux-gnu, applying to trunk. commit d31ae27e292c03ab16feb0ac714ec62b12165444 Author: Jason Merrill Date: Mon Mar 11 16:35:02 2013 -0400 PR c++/56039 * tree.c (strip_typedefs_expr): Complain about lambda, don't abort. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9707825..713ec86 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1421,7 +1421,8 @@ strip_typedefs_expr (tree t) } case LAMBDA_EXPR: - gcc_unreachable (); + error ("lambda-expression in a constant expression"); + return error_mark_node; default: break; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C new file mode 100644 index 0000000..973f8a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C @@ -0,0 +1,55 @@ +// PR c++/56039 +// { dg-do compile { target c++11 } } + +template struct BoolSink { typedef void type; }; + +template +struct AddRvalueReferenceImpl { typedef T type; }; + +template +struct AddRvalueReferenceImpl::type> { // { dg-error "lambda" } + typedef T &&type; +}; + +template +struct AddRvalueReference : AddRvalueReferenceImpl { }; + +namespace ImplHelpers { + template + typename AddRvalueReference::type create(void) { } +} + +template +struct IsConstructibleImpl { enum { value = 0 }; }; + +template +struct IsConstructibleImpl() ...); + }>::type, Args ...> { // { dg-error "lambda" } + enum { value = 1 }; +}; + +template +struct IsConstructible : IsConstructibleImpl { }; + +struct DestroyMe { + ~DestroyMe() = delete; +}; + +static_assert(+IsConstructible::value, "error"); +static_assert(!IsConstructible::value, "error"); +static_assert(+IsConstructible::value, "error"); +static_assert(!IsConstructible::value, "error"); +static_assert(!IsConstructible::value, "error"); + +static_assert(+IsConstructible::value, "error"); +static_assert(!IsConstructible::value, "error"); +static_assert(+IsConstructible::value, "error"); + +// { dg-prune-output "expected" } +// { dg-prune-output "does not name a class" } +// { dg-prune-output "static assertion" }