&& !AUTO_IS_DECLTYPE (type)
&& CONSTRUCTOR_NELTS (compound_literal) == 1)
{
- if (cxx_dialect < cxx23)
+ if (is_constrained_auto (type))
+ {
+ if (complain & tf_error)
+ error ("%<auto{x}%> cannot be constrained");
+ return error_mark_node;
+ }
+ else if (cxx_dialect < cxx23)
pedwarn (input_location, OPT_Wc__23_extensions,
"%<auto{x}%> only available with "
"%<-std=c++2b%> or %<-std=gnu++2b%>");
&& list_length (parms) == 1)
{
init = TREE_VALUE (parms);
- if (cxx_dialect < cxx23)
+ if (is_constrained_auto (anode))
+ {
+ if (complain & tf_error)
+ error_at (loc, "%<auto(x)%> cannot be constrained");
+ return error_mark_node;
+ }
+ else if (cxx_dialect < cxx23)
pedwarn (loc, OPT_Wc__23_extensions,
"%<auto(x)%> only available with "
"%<-std=c++2b%> or %<-std=gnu++2b%>");
--- /dev/null
+// PR c++/104752
+// { dg-do compile { target c++23 } }
+
+template<class T>
+concept C = true;
+auto x = auto(1); // valid (P0849R8)
+auto y = C auto(1); // { dg-error "cannot be constrained" }
+auto z = C auto{1}; // { dg-error "cannot be constrained" }