]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: 'requires' diagnostic before C++20
authorJason Merrill <jason@redhat.com>
Tue, 28 Jan 2025 22:46:59 +0000 (17:46 -0500)
committerJason Merrill <jason@redhat.com>
Thu, 17 Apr 2025 17:18:44 +0000 (13:18 -0400)
We were giving a generic "not declared" error for a requires-expression
without concepts enabled; we can do better.

gcc/cp/ChangeLog:

* lex.cc (unqualified_name_lookup_error): Handle 'requires' better.

gcc/cp/lex.cc

index c12b084aad99d051e92fc9c89378e41c2d28ec10..12af81ed078cc5a496bbc31abb1f3ae7f56872a6 100644 (file)
@@ -749,6 +749,9 @@ unqualified_name_lookup_error (tree name, location_t loc)
 
   if (IDENTIFIER_ANY_OP_P (name))
     error_at (loc, "%qD not defined", name);
+  else if (!flag_concepts && name == ridpointers[(int)RID_REQUIRES])
+    error_at (loc, "%<requires%> only available with %<-std=c++20%> or "
+             "%<-fconcepts%>");
   else
     {
       if (!objc_diagnose_private_ivar (name))