public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: address of NTTP object as targ [PR113242]
Date: Mon, 15 Jan 2024 16:00:14 -0500	[thread overview]
Message-ID: <a65524ef-e9c9-45e9-87f7-aa2a47ae3dc6@redhat.com> (raw)
In-Reply-To: <20240105165056.571235-1-ppalka@redhat.com>

On 1/5/24 11:50, Patrick Palka wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK
> for trunk and perhaps 13?
> 
> -- >8 --
> 
> invalid_tparm_referent_p was rejecting using the address of a class NTTP
> object as a template argument, but this should be fine.

Hmm, I suppose so; https://eel.is/c++draft/temp#param-8 saying "No two 
template parameter objects are template-argument-equivalent" suggests 
there can be only one.  And clang/msvc allow it.

> 	PR c++/113242
> 
> gcc/cp/ChangeLog:
> 
> 	* pt.cc (invalid_tparm_referent_p) <case ADDR_EXPR>: Suppress
> 	DECL_ARTIFICIAL rejection test for class NTTP objects.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/cpp2a/nontype-class61.C: New test.
> ---
>   gcc/cp/pt.cc                                 |  3 ++-
>   gcc/testsuite/g++.dg/cpp2a/nontype-class61.C | 27 ++++++++++++++++++++
>   2 files changed, 29 insertions(+), 1 deletion(-)
>   create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class61.C
> 
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 154ac76cb65..8c7d178328d 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -7219,7 +7219,8 @@ invalid_tparm_referent_p (tree type, tree expr, tsubst_flags_t complain)
>   	   * a string literal (5.13.5),
>   	   * the result of a typeid expression (8.2.8), or
>   	   * a predefined __func__ variable (11.4.1).  */
> -	else if (VAR_P (decl) && DECL_ARTIFICIAL (decl))
> +	else if (VAR_P (decl) && !DECL_NTTP_OBJECT_P (decl)
> +		 && DECL_ARTIFICIAL (decl))

If now some artificial variables are OK and others are not, perhaps we 
should enumerate them either way and abort if it's one we haven't 
specifically considered.

Jason


  parent reply	other threads:[~2024-01-15 21:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05 16:50 Patrick Palka
2024-01-15 19:34 ` Patrick Palka
2024-01-15 21:00 ` Jason Merrill [this message]
2024-01-17 15:43   ` Patrick Palka
2024-01-17 16:34     ` 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=a65524ef-e9c9-45e9-87f7-aa2a47ae3dc6@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@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).