From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: Add !TYPE_P assert to type_dependent_expression_p [PR99080]
Date: Fri, 27 May 2022 11:52:12 -0400 [thread overview]
Message-ID: <c5aec165-0918-cbe5-a5b1-1e1fd9b63660@redhat.com> (raw)
In-Reply-To: <20220527003343.537118-1-polacek@redhat.com>
On 5/26/22 20:33, Marek Polacek wrote:
> As discussed here:
> <https://gcc.gnu.org/pipermail/gcc-patches/2021-February/564629.html>,
> type_dependent_expression_p should not be called with a type argument.
>
> I promised I'd add an assert so here it is. One place needed adjusting,
> the comment explains why.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
>
> PR c++/99080
>
> gcc/cp/ChangeLog:
>
> * pt.cc (type_dependent_expression_p): Assert !TYPE_P.
> * semantics.cc (finish_id_expression_1): Don't call
> type_dependent_expression_p for a type.
> ---
> gcc/cp/pt.cc | 2 ++
> gcc/cp/semantics.cc | 4 +++-
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 24bbe2f4060..89156cb88b4 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -27727,6 +27727,8 @@ type_dependent_expression_p (tree expression)
> if (expression == NULL_TREE || expression == error_mark_node)
> return false;
>
> + gcc_checking_assert (!TYPE_P (expression));
> +
> STRIP_ANY_LOCATION_WRAPPER (expression);
>
> /* An unresolved name is always dependent. */
> diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
> index cd7a2818feb..7f8502f49b0 100644
> --- a/gcc/cp/semantics.cc
> +++ b/gcc/cp/semantics.cc
> @@ -4141,7 +4141,9 @@ finish_id_expression_1 (tree id_expression,
> }
> else
> {
> - bool dependent_p = type_dependent_expression_p (decl);
> + /* DECL could be e.g. UNBOUND_CLASS_TEMPLATE which is a type which
> + t_d_e_p doesn't accept. */
> + bool dependent_p = !TYPE_P (decl) && type_dependent_expression_p (decl);
Maybe instead we could handle UNBOUND_CLASS_TEMPLATE at a higher level
in the function, like with an 'else if' before this 'else'?
> /* If the declaration was explicitly qualified indicate
> that. The semantics of `A::f(3)' are different than
>
> base-commit: 367740bf6d3a6627798b3955e5d85efc7549ef50
next prev parent reply other threads:[~2022-05-27 15:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 0:33 Marek Polacek
2022-05-27 15:52 ` Jason Merrill [this message]
2022-05-27 16:43 ` Marek Polacek
2022-05-30 2:06 ` 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=c5aec165-0918-cbe5-a5b1-1e1fd9b63660@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=polacek@redhat.com \
/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).