c++: trait as typename scope [PR116052]

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.
This commit is contained in:
Jason Merrill 2024-07-25 23:09:31 -04:00
parent 2fb5bbe5ee
commit ea381d87ec
2 changed files with 18 additions and 1 deletions

View file

@ -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;

View file

@ -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>();
}