On 19/05/21 17:39 +0100, Jonathan Wakely wrote:
Jakub pointed out I'd forgotten the spaces before the opening parens
for function calls. The attached patch should fix all those, with no
other changes.

Tested x86_64-linux. OK for trunk?

Jakub also pointed out we already have some similar diagnostics for
C++23, but I missed them as they say "only optional with" not "only
available with".

I'm testing the incremental change in the attached patch which also
adds -Wc++23-extensions, and I'll resend the full patch after that
finishes.

(Thanks, Jakub!)


diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index a7605cf3a38..9fc41d9f2b3 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -447,6 +447,10 @@ Wc++20-extensions
 C++ ObjC++ Var(warn_cxx20_extensions) Warning LangEnabledBy(C++ ObjC++,Wall) Init(1)
 Warn about C++20 constructs in code compiled with an older standard.
 
+Wc++23-extensions
+C++ ObjC++ Var(warn_cxx23_extensions) Warning LangEnabledBy(C++ ObjC++,Wall) Init(1)
+Warn about C++23 constructs in code compiled with an older standard.
+
 Wcast-function-type
 C ObjC C++ ObjC++ Var(warn_cast_function_type) Warning EnabledBy(Wextra)
 Warn about casts between incompatible function types.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3652649c6c6..ba11a436499 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -11390,7 +11390,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
 
   if (omitted_parms_loc && lambda_specs.any_specifiers_p)
     {
-      pedwarn (omitted_parms_loc, 0,
+      pedwarn (omitted_parms_loc, OPT_Wc__23_extensions,
 	       "parameter declaration before lambda declaration "
 	       "specifiers only optional with %<-std=c++2b%> or "
 	       "%<-std=gnu++2b%>");
@@ -11409,7 +11409,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
   tx_qual = cp_parser_tx_qualifier_opt (parser);
   if (omitted_parms_loc && tx_qual)
     {
-      pedwarn (omitted_parms_loc, 0,
+      pedwarn (omitted_parms_loc, OPT_Wc__23_extensions,
 	       "parameter declaration before lambda transaction "
 	       "qualifier only optional with %<-std=c++2b%> or "
 	       "%<-std=gnu++2b%>");
@@ -11422,7 +11422,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
 
   if (omitted_parms_loc && exception_spec)
     {
-      pedwarn (omitted_parms_loc, 0,
+      pedwarn (omitted_parms_loc, OPT_Wc__23_extensions,
 	       "parameter declaration before lambda exception "
 	       "specification only optional with %<-std=c++2b%> or "
 	       "%<-std=gnu++2b%>");
@@ -11440,7 +11440,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
   if (cp_lexer_next_token_is (parser->lexer, CPP_DEREF))
     {
       if (omitted_parms_loc)
-	pedwarn (omitted_parms_loc, 0,
+	pedwarn (omitted_parms_loc, OPT_Wc__23_extensions,
 		 "parameter declaration before lambda trailing "
 		 "return type only optional with %<-std=c++2b%> or "
 		 "%<-std=gnu++2b%>");

Reply via email to