From patchwork Mon Mar 28 15:49:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 88625 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 CCCD3B6F7A for ; Tue, 29 Mar 2011 02:49:56 +1100 (EST) Received: (qmail 5940 invoked by alias); 28 Mar 2011 15:49:48 -0000 Received: (qmail 5919 invoked by uid 22791); 28 Mar 2011 15:49:46 -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, 28 Mar 2011 15:49:35 +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 p2SFnYtU018077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 28 Mar 2011 11:49:34 -0400 Received: from [127.0.0.1] ([10.3.113.2]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2SFnXqA005460 for ; Mon, 28 Mar 2011 11:49:34 -0400 Message-ID: <4D90AE0C.6020402@redhat.com> Date: Mon, 28 Mar 2011 11:49:32 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH to fix constexpr/noexcept bug 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 We need to call cxx_constant_value after converting to bool, in case the conversion uses a conversion operator. Tested x86_64-pc-linux-gnu, applying to trunk and 4.6. commit a3fde3e7dcdc6b4f0b92bb273f4267c6bf8f6de0 Author: Jason Merrill Date: Sun Mar 27 21:51:35 2011 -0400 * except.c (build_noexcept_spec): Call cxx_constant_value after converting to bool. diff --git a/gcc/cp/except.c b/gcc/cp/except.c index c05e507..a814d67 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1203,10 +1203,10 @@ build_noexcept_spec (tree expr, int complain) it until instantiation. */ if (!processing_template_decl) { - expr = cxx_constant_value (expr); expr = perform_implicit_conversion_flags (boolean_type_node, expr, complain, LOOKUP_NORMAL); + expr = cxx_constant_value (expr); } if (expr == boolean_true_node) return noexcept_true_spec; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept5.C new file mode 100644 index 0000000..7bf961b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept5.C @@ -0,0 +1,15 @@ +// { dg-options -std=c++0x } + +struct booleable { + bool data; + constexpr explicit operator bool() { return data; } +}; + +constexpr booleable truthy_func() { return {true}; } + +void funky() noexcept(truthy_func()) {} + +int main() { + funky(); + return 0; +}