public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: trait as typename scope [PR116052]
Date: Fri, 26 Jul 2024 15:28:53 -0400	[thread overview]
Message-ID: <20240726192956.3672432-1-jason@redhat.com> (raw)

Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

The stdexec library currently wrongly ends up using __decay as the scope of
a typename, which leads to a crash.  Let's give an error instead.

	PR c++/116052

gcc/cp/ChangeLog:

	* mangle.cc (write_prefix): Handle TRAIT_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/decay1.C: New test.
---
 gcc/cp/mangle.cc                  |  3 ++-
 gcc/testsuite/g++.dg/ext/decay1.C | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ext/decay1.C

diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index a04bc584586..e7391220234 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -1300,7 +1300,8 @@ write_prefix (const tree node)
 
   MANGLE_TRACE_TREE ("prefix", node);
 
-  if (TREE_CODE (node) == DECLTYPE_TYPE)
+  if (TREE_CODE (node) == DECLTYPE_TYPE
+      || TREE_CODE (node) == TRAIT_TYPE)
     {
       write_type (node);
       return;
diff --git a/gcc/testsuite/g++.dg/ext/decay1.C b/gcc/testsuite/g++.dg/ext/decay1.C
new file mode 100644
index 00000000000..dd457ba307c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/decay1.C
@@ -0,0 +1,16 @@
+// PR c++/116052
+// { dg-do compile { target c++11 } }
+
+template <class T> using decay_t = __decay(T);
+template <class T> void g(typename decay_t<T>::foo); // { dg-error "built-in" }
+template <class T> void f()
+{
+  g<T>(0);
+}
+
+struct A { using foo = int; };
+
+int main()
+{
+  f<A>();
+}

base-commit: 2fb5bbe5ee9c148cd7d1068b18be66cc52054812
-- 
2.45.2


                 reply	other threads:[~2024-07-26 19:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240726192956.3672432-1-jason@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.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).