From: Alexandre Oliva <oliva@gnu.org>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org, nathan@acm.org
Subject: Re: [PATCH] [PR86397] set p_t_decl while canonicalizing eh specs for mangling
Date: Wed, 28 Nov 2018 04:54:00 -0000 [thread overview]
Message-ID: <orh8g1ls3x.fsf@lxoliva.fsfla.org> (raw)
In-Reply-To: <ab1fc43f-6117-17c1-da8b-7598b7b6dc9c@redhat.com> (Jason Merrill's message of "Tue, 27 Nov 2018 17:40:53 -0500")
On Nov 27, 2018, Jason Merrill <jason@redhat.com> 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 complain)
it until instantiation. */
if (TREE_CODE (expr) != DEFERRED_NOEXCEPT
&& (!processing_template_decl
- || (flag_noexcept_type && !value_dependent_expression_p (expr))))
+ || !value_dependent_expression_p (expr)))
{
expr = 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) == METHOD_TYPE)
{
node = build_ref_qualified_type (node, type_memfn_rqual (orig));
- tree r = canonical_eh_spec (TYPE_RAISES_EXCEPTIONS (orig));
+ tree r = TYPE_RAISES_EXCEPTIONS (orig);
if (flag_noexcept_type)
- node = build_exception_variant (node, r);
+ {
+ r = canonical_eh_spec (r);
+ node = 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?
--
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ás-GNUChe
next prev parent reply other threads:[~2018-11-28 4:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-22 23:40 Alexandre Oliva
2018-11-27 22:40 ` Jason Merrill
2018-11-28 4:54 ` Alexandre Oliva [this message]
2018-11-29 3:27 ` Jason Merrill
2018-12-05 6:32 ` Alexandre Oliva
2018-12-05 15:54 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=orh8g1ls3x.fsf@lxoliva.fsfla.org \
--to=oliva@gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=nathan@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).