* [pushed] c++: trait as typename scope [PR116052]
@ 2024-07-26 19:28 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2024-07-26 19:28 UTC (permalink / raw)
To: gcc-patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-07-26 19:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-26 19:28 [pushed] c++: trait as typename scope [PR116052] Jason Merrill
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).