^^B <int> is a type alias though. */
if (TYPE_P (t) && !type_alias_p)
t = strip_typedefs (t);
+ /* [expr.reflect] If the type-id designates a placeholder type, R is
+ ill-formed. This check is here rather than in get_reflection so
+ that we don't wrongly error for a return-type-requirement which is
+ represented as a constrained auto. */
+ if (is_auto (t))
+ {
+ error_at (loc, "%<^^%> cannot be applied to a placeholder type");
+ return error_mark_node;
+ }
return get_reflection (loc, t);
}
/* Try an id-expression. */
{
STRIP_ANY_LOCATION_WRAPPER (t);
- /* [expr.reflect] If the type-id designates a placeholder type, R is
- ill-formed. */
- if (is_auto (t))
- {
- error_at (loc, "%<^^%> cannot be applied to a placeholder type");
- return error_mark_node;
- }
/* Constant template parameters and pack-index-expressions cannot
appear as operands of the reflection operator. */
- else if (PACK_INDEX_P (t))
+ if (PACK_INDEX_P (t))
{
error_at (loc, "%<^^%> cannot be applied to a pack index");
return error_mark_node;
--- /dev/null
+// PR c++/124457
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+template <class T, auto t = ^^T>
+concept True = true;
+
+template <class T>
+concept AlsoTrue = requires (T t) {
+ { t } -> True;
+};
+void f1(True auto x);
+template <True T> void f2(T );
+auto f3(int) -> True auto;