From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13725 invoked by alias); 6 Dec 2012 07:24:57 -0000 Received: (qmail 13711 invoked by uid 22791); 6 Dec 2012 07:24:55 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_FN 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; Thu, 06 Dec 2012 07:24:46 +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 qB67Ojhu022784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Dec 2012 02:24:45 -0500 Received: from zalov.redhat.com (vpn1-6-17.ams2.redhat.com [10.36.6.17]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB67OhPA004630 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Dec 2012 02:24:45 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qB67OhJE012954; Thu, 6 Dec 2012 08:24:43 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qB67Ogfq012953; Thu, 6 Dec 2012 08:24:42 +0100 Date: Thu, 06 Dec 2012 07:24:00 -0000 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix build_noexcept_spec ICE (PR c++/54207) Message-ID: <20121206072442.GG2315@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00377.txt.bz2 Hi! We ICE on the following testcase, because perform_implicit_conversion_flags doesn't guarantee the type of the returned value is boolean_type_node, if it is some other type compatible with it (in the same_type_p sense), then simple == boolean_true_node and == boolean_false_node comparisons don't really work. Either we could fold_convert it to boolean_type_node if INTEGER_CST first, or we can use operand_equal_p to compare instead of pointer comparisons. The INTEGER_CSTs checks in the patch are to avoid calling operand_equal_p unnecessarily, but could be dropped if you prefer it that way. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-12-06 Jakub Jelinek PR c++/54207 * except.c (build_noexcept_spec): Avoid direct comparison with boolean_true_node or boolean_false_node, instead use operand_equal_p. * pt.c (tsubst_exception_specification): Likewise. * typeck2.c (merge_exception_specifiers): Likewise. * g++.dg/cpp0x/noexcept18.C: New test. --- gcc/cp/except.c.jj 2012-11-19 14:41:16.000000000 +0100 +++ gcc/cp/except.c 2012-12-04 11:51:38.157724775 +0100 @@ -1316,15 +1316,18 @@ build_noexcept_spec (tree expr, int comp LOOKUP_NORMAL); expr = cxx_constant_value (expr); } - if (expr == boolean_true_node) - return noexcept_true_spec; - else if (expr == boolean_false_node) - return noexcept_false_spec; - else if (expr == error_mark_node) + if (TREE_CODE (expr) == INTEGER_CST) + { + if (operand_equal_p (expr, boolean_true_node, 0)) + return noexcept_true_spec; + else if (operand_equal_p (expr, boolean_false_node, 0)) + return noexcept_false_spec; + } + if (expr == error_mark_node) return error_mark_node; else { - gcc_assert (processing_template_decl || expr == error_mark_node + gcc_assert (processing_template_decl || TREE_CODE (expr) == DEFERRED_NOEXCEPT); return build_tree_list (expr, NULL_TREE); } --- gcc/cp/pt.c.jj 2012-12-01 00:50:33.000000000 +0100 +++ gcc/cp/pt.c 2012-12-04 11:53:32.007085060 +0100 @@ -10840,8 +10840,14 @@ tsubst_exception_specification (tree fnt { /* A noexcept-specifier. */ tree expr = TREE_PURPOSE (specs); - if (expr == boolean_true_node || expr == boolean_false_node) - new_specs = expr; + if (TREE_CODE (expr) == INTEGER_CST) + { + if (operand_equal_p (expr, boolean_true_node, 0) + || operand_equal_p (expr, boolean_false_node, 0)) + new_specs = expr; + } + if (new_specs != NULL_TREE) + ; else if (defer_ok) { /* Defer instantiation of noexcept-specifiers to avoid --- gcc/cp/typeck2.c.jj 2012-11-19 14:41:16.000000000 +0100 +++ gcc/cp/typeck2.c 2012-12-04 11:54:34.184735478 +0100 @@ -1871,7 +1871,7 @@ merge_exception_specifiers (tree list, t /* If ADD is a deferred noexcept, we must have been called from process_subob_fn. For implicitly declared functions, we build up a list of functions to consider at instantiation time. */ - if (noex == boolean_true_node) + if (operand_equal_p (noex, boolean_true_node, 0)) noex = NULL_TREE; gcc_assert (fn && (!noex || is_overloaded_fn (noex))); noex = build_overload (fn, noex); --- gcc/testsuite/g++.dg/cpp0x/noexcept18.C.jj 2012-12-04 11:56:32.910049983 +0100 +++ gcc/testsuite/g++.dg/cpp0x/noexcept18.C 2012-12-04 11:55:50.000000000 +0100 @@ -0,0 +1,11 @@ +// PR c++/54207 +// { dg-do compile } +// { dg-options "-std=c++11" } + +typedef bool B; +constexpr B foo () { return true; } + +void +bar () noexcept (foo ()) +{ +} Jakub