From patchwork Thu May 23 03:21:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 245800 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 45F6A2C00A3 for ; Thu, 23 May 2013 13:21:33 +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=qugLCduTRqlC7fKrySa/XaVnvdpLtueGJCfdT/K40ZbyPl 5AFD2uY2CX7aZXcGpdKOXJeb7bX0SxriRfIZCC60oBgYgQS31716WAHrWC8H+D5I 6i6TswYWK6xhGOoeyxPFWmPosNGvOcp5nf8odDfyIqz2sD80SkJXYEoegOE6I= 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=JNFdll4l37y58UK5Yt6DJbCfucw=; b=KLOhj+kswFPRxbPhw1zw bGzLbc+DFjBDnFvwRB/YA/RhdQGZmytWCyEKTmo+7mPkYxyz7akFwzVIupH2dzvf NE4rpNTy5+s52xxSWwDEGQRGU72At3Yr/yFVbGarBtTFy+VrFPQtC09zH7bZgjNz HrlI17fd116Tui7dGUsjPpc= Received: (qmail 17628 invoked by alias); 23 May 2013 03:21:26 -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 17618 invoked by uid 89); 23 May 2013 03:21:26 -0000 X-Spam-SWARE-Status: No, score=-7.0 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; Thu, 23 May 2013 03:21:25 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4N3LOIp023765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 22 May 2013 23:21:24 -0400 Received: from [10.3.113.91] (ovpn-113-91.phx2.redhat.com [10.3.113.91]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4N3LNH7019013 for ; Wed, 22 May 2013 23:21:23 -0400 Message-ID: <519D8B2F.8040308@redhat.com> Date: Wed, 22 May 2013 23:21:19 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:23.0) Gecko/20100101 Thunderbird/23.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/56915 (ICE after error with lambda) X-Virus-Found: No If we run into an error during template instantiation, we try to avoid starting more instantiations in order to limit the error cascade. If as a result of this we decide not to instantiate a lambda call operator, we shouldn't try to generate a conversion operator. Tested x86_64-pc-linux-gnu, applying to trunk. commit 84548604f1d5b2f175babe2fa3501ed14cec2db4 Author: Jason Merrill Date: Tue May 21 17:24:16 2013 -0400 PR c++/56915 * semantics.c (maybe_add_lambda_conv_op): Give up if the call op isn't defined. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 92a4917..5b36337 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9784,6 +9784,13 @@ maybe_add_lambda_conv_op (tree type) if (processing_template_decl) return; + if (DECL_INITIAL (callop) == NULL_TREE) + { + /* If the op() wasn't instantiated due to errors, give up. */ + gcc_assert (errorcount || sorrycount); + return; + } + stattype = build_function_type (TREE_TYPE (TREE_TYPE (callop)), FUNCTION_ARG_CHAIN (callop)); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C new file mode 100644 index 0000000..520b804 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template11.C @@ -0,0 +1,25 @@ +// PR c++/56915 +// { dg-require-effective-target c++11 } + +template +class A +{ + typename T::type b(); // { dg-error "int" } +}; + +template +void waldo(T, U) {} + +template +void bar() +{ + waldo([](A a){ return a; }, + []{}); +} + +int main() +{ + bar(); +} + +// { dg-prune-output "used but never defined" }