[dcl.constinit]/1: The constinit specifier shall be applied only to a declaration
of a variable with static or thread storage duration.
and while we detect
constinit int fn();
we weren't detecting
using F = int();
constinit F f;
PR c++/111173
gcc/cp/ChangeLog:
* decl.cc (grokdeclarator): Disallow constinit on functions.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constinit19.C: New test.
"storage class %<thread_local%> invalid for "
"function %qs", name);
}
+ else if (constinit_p)
+ error_at (declspecs->locations[ds_constinit],
+ "%<constinit%> specifier invalid for function %qs", name);
if (virt_specifiers)
error ("virt-specifiers in %qs not allowed outside a class "
--- /dev/null
+// PR c++/111173
+// { dg-do compile { target c++20 } }
+
+using Function = int();
+constinit Function f; // { dg-error ".constinit. specifier invalid for function" }