From patchwork Mon May 23 15:48:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 96974 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 376A4B6FB5 for ; Tue, 24 May 2011 01:48:28 +1000 (EST) Received: (qmail 9876 invoked by alias); 23 May 2011 15:48:18 -0000 Received: (qmail 9861 invoked by uid 22791); 23 May 2011 15:48:17 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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; Mon, 23 May 2011 15:48:03 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4NFm37W031699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 May 2011 11:48:03 -0400 Received: from [127.0.0.1] ([10.3.113.3]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4NFm2JW022179 for ; Mon, 23 May 2011 11:48:02 -0400 Message-ID: <4DDA81B2.1090101@redhat.com> Date: Mon, 23 May 2011 11:48:02 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/47263 (missing eh-spec on lambda) 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 G++ was omitting code for the exception specification on the lambda because it was confusing it with an synthesized constructor. This patch fixes the test to match the comment better; not all artificial methods are [cd]tors. Tested x86_64-pc-linux-gnu, applying to trunk. commit 79adecb0b52f58792a2a2f05394f3df13e2b7fcc Author: Jason Merrill Date: Sun May 22 16:29:27 2011 -0400 PR c++/47263 * decl.c (use_eh_spec_block): Do use an EH spec block for a lambda op(). diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 733157a..234daaf 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12759,7 +12759,7 @@ use_eh_spec_block (tree fn) not creating the EH_SPEC_BLOCK we save a little memory, and we avoid spurious warnings about unreachable code. */ - && !DECL_ARTIFICIAL (fn)); + && !DECL_DEFAULTED_FN (fn)); } /* Store the parameter declarations into the current function declaration. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C new file mode 100644 index 0000000..1490a25 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C @@ -0,0 +1,16 @@ +// PR c++/47263 +// { dg-options -std=c++0x } +// { dg-do run } + +#include + +int main( void ) +{ + std::set_unexpected( []{ throw 0; } ); + try + { + []() throw( int ) { throw nullptr; }(); + } + catch( int ) + { } +}