From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59646 invoked by alias); 28 Nov 2018 04:54:40 -0000 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 Received: (qmail 59633 invoked by uid 89); 28 Nov 2018 04:54:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=hay, pero, free!, Latin X-HELO: linux-libre.fsfla.org Received: from linux-libre.fsfla.org (HELO linux-libre.fsfla.org) (208.118.235.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Nov 2018 04:54:36 +0000 Received: from free.home (home.lxoliva.fsfla.org [172.31.160.164]) by linux-libre.fsfla.org (8.15.2/8.15.2/Debian-3) with ESMTP id wAS4sH6f015177; Wed, 28 Nov 2018 04:54:18 GMT Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTP id wAS4sAvk732925; Wed, 28 Nov 2018 02:54:10 -0200 From: Alexandre Oliva To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, nathan@acm.org Subject: Re: [PATCH] [PR86397] set p_t_decl while canonicalizing eh specs for mangling References: Date: Wed, 28 Nov 2018 04:54:00 -0000 In-Reply-To: (Jason Merrill's message of "Tue, 27 Nov 2018 17:40:53 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg02262.txt.bz2 On Nov 27, 2018, Jason Merrill wrote: > On 11/22/18 6:40 PM, Alexandre Oliva wrote: >> Mangling visits the base template function type, prior to template >> resolution, and on such types, exception specifications may contain >> unresolved noexcept expressions. nothrow_spec_p is called on them >> even when exception specifications are not part of function types, and >> it rejects unresolved noexcept expressions if processing_template_decl >> is not set. > The problem here is that the noexcept expression is unresolved even > though it isn't dependent Yeah, but that seems to be on purpose, according to these comments, that precede the hunk below. /* This isn't part of the signature, so don't bother trying to evaluate it until instantiation. */ Taking out the 'flag_noexcept_type && ' subexpr fixes the problem, but defeats the intended deferral of unnecessary computation: diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 3449b59b3cc0..dbd233c94c3a 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1193,7 +1193,7 @@ build_noexcept_spec (tree expr, tsubst_flags_t compla= in) it until instantiation. */ if (TREE_CODE (expr) !=3D DEFERRED_NOEXCEPT && (!processing_template_decl - || (flag_noexcept_type && !value_dependent_expression_p (expr)))) + || !value_dependent_expression_p (expr))) { expr =3D perform_implicit_conversion_flags (boolean_type_node, expr, complain, In order to retain that deferral, we could change the mangling logic to also refrain from canonicalizing the EH spec when it's not part of the type: diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 64415894bc57..4c8086c9f9bd 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -418,9 +418,12 @@ canonicalize_for_substitution (tree node) || TREE_CODE (node) =3D=3D METHOD_TYPE) { node =3D build_ref_qualified_type (node, type_memfn_rqual (orig)); - tree r =3D canonical_eh_spec (TYPE_RAISES_EXCEPTIONS (orig)); + tree r =3D TYPE_RAISES_EXCEPTIONS (orig); if (flag_noexcept_type) - node =3D build_exception_variant (node, r); + { + r =3D canonical_eh_spec (r); + node =3D build_exception_variant (node, r); + } else /* Set the warning flag if appropriate. */ write_exception_spec (r); This would bypass the nothrow_spec_p call in canonical_eh_spec at C++1[14], but it might produce unintended -Wnoexcept-type warnings when the noexcept expression would resolve to false. The canonical_eh_spec call wouldn't have avoided it anyway. Which one? --=20 Alexandre Oliva, freedom fighter https://FSFLA.org/blogs/lxo Be the change, be Free! FSF Latin America board member GNU Toolchain Engineer Free Software Evangelist Hay que enGNUrecerse, pero sin perder la terGNUra jam=C3=A1s-GNUChe