Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/cp/lex.cc b/gcc/cp/lex.cc
index c12b084aad9..12af81ed078 100644
--- a/gcc/cp/lex.cc
+++ b/gcc/cp/lex.cc
@@ -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))

base-commit: 7c47badcdc8625ea53aed275be96c32bc78db25b
-- 
2.49.0

Reply via email to