aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r--gcc/cp/parser.cc89
1 files changed, 44 insertions, 45 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 57a4610..812a7c5 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -3901,10 +3901,10 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id,
inform (location, "%qE is not recognized as a module control-line",
id);
else if (cxx_dialect < cxx20)
- inform (location, "C++20 %qE only available with %<-fmodules-ts%>",
+ inform (location, "C++20 %qE only available with %<-fmodules%>",
id);
else
- inform (location, "C++20 %qE only available with %<-fmodules-ts%>"
+ inform (location, "C++20 %qE only available with %<-fmodules%>"
", which is not yet enabled with %<-std=c++20%>", id);
}
else if (cxx_dialect < cxx11
@@ -11736,21 +11736,34 @@ cp_parser_lambda_expression (cp_parser* parser)
if (cp_parser_error_occurred (parser))
return error_mark_node;
- type = begin_lambda_type (lambda_expr);
- if (type == error_mark_node)
- return error_mark_node;
+ {
+ /* OK, this is a bit tricksy. cp_parser_requires_expression sets
+ processing_template_decl to make checking more normal, but that confuses
+ lambda parsing terribly. In non-template context, we want to parse the
+ lambda once and not tsubst_lambda_expr. So in that case, clear
+ processing_template_decl now, and restore it before the call to
+ build_lambda_object; that way we end up with what looks like a templatey
+ functional cast to the closure type, which is suitable for the
+ requires-expression tsubst_expr. This is PR99546 and friends. */
+ processing_template_decl_sentinel ptds (/*reset*/false);
+ if (processing_template_decl && !in_template_context
+ && current_binding_level->requires_expression)
+ processing_template_decl = 0;
+
+ type = begin_lambda_type (lambda_expr);
+ if (type == error_mark_node)
+ return error_mark_node;
- record_lambda_scope (lambda_expr);
- record_lambda_scope_discriminator (lambda_expr);
+ record_lambda_scope (lambda_expr);
+ record_lambda_scope_discriminator (lambda_expr);
- /* Do this again now that LAMBDA_EXPR_EXTRA_SCOPE is set. */
- determine_visibility (TYPE_NAME (type));
+ /* Do this again now that LAMBDA_EXPR_EXTRA_SCOPE is set. */
+ determine_visibility (TYPE_NAME (type));
- /* Now that we've started the type, add the capture fields for any
- explicit captures. */
- register_capture_members (LAMBDA_EXPR_CAPTURE_LIST (lambda_expr));
+ /* Now that we've started the type, add the capture fields for any
+ explicit captures. */
+ register_capture_members (LAMBDA_EXPR_CAPTURE_LIST (lambda_expr));
- {
/* Inside the class, surrounding template-parameter-lists do not apply. */
unsigned int saved_num_template_parameter_lists
= parser->num_template_parameter_lists;
@@ -11773,6 +11786,9 @@ cp_parser_lambda_expression (cp_parser* parser)
parser->auto_is_implicit_function_template_parm_p = false;
parser->omp_array_section_p = false;
+ /* Inside the lambda, outside unevaluated context do not apply. */
+ cp_evaluated ev;
+
/* The body of a lambda in a discarded statement is not discarded. */
bool discarded = in_discarded_stmt;
in_discarded_stmt = 0;
@@ -18842,7 +18858,7 @@ cp_parser_template_declaration (cp_parser* parser, bool member_p)
else if (cxx_dialect < cxx20)
warning (0, "keyword %<export%> is deprecated, and is ignored");
else
- warning (0, "keyword %<export%> is enabled with %<-fmodules-ts%>");
+ warning (0, "keyword %<export%> is enabled with %<-fmodules%>");
}
cp_parser_template_declaration_after_export (parser, member_p);
@@ -43118,8 +43134,8 @@ cp_parser_omp_clause_init_modifiers (cp_parser *parser, bool *target,
while (true);
fail:
- cp_parser_error (parser, "%<init%> clause with modifier other than "
- "%<prefer_type%>, %<target%> or %<targetsync%>");
+ cp_parser_error (parser,
+ "expected %<prefer_type%>, %<target%>, or %<targetsync%>");
return false;
}
@@ -43137,39 +43153,14 @@ cp_parser_omp_clause_init (cp_parser *parser, tree list)
if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list;
- unsigned raw_pos = 1;
- while (cp_lexer_peek_nth_token (parser->lexer, raw_pos)->type == CPP_NAME)
- {
- raw_pos++;
- if (cp_lexer_peek_nth_token (parser->lexer, raw_pos)->type
- == CPP_OPEN_PAREN)
- {
- unsigned n = cp_parser_skip_balanced_tokens (parser, raw_pos);
- if (n == raw_pos)
- {
- raw_pos = 0;
- break;
- }
- raw_pos = n;
- }
- if (cp_lexer_peek_nth_token (parser->lexer, raw_pos)->type == CPP_COLON)
- break;
- if (cp_lexer_peek_nth_token (parser->lexer, raw_pos)->type != CPP_COMMA)
- {
- raw_pos = 0;
- break;
- }
- raw_pos++;
- }
-
bool target = false;
bool targetsync = false;
tree prefer_type_tree = NULL_TREE;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
- if (raw_pos > 1
- && (!cp_parser_omp_clause_init_modifiers (parser, &target, &targetsync,
- &prefer_type_tree)
- || !cp_parser_require (parser, CPP_COLON, RT_COLON)))
+ if (!cp_parser_omp_clause_init_modifiers (parser, &target, &targetsync,
+ &prefer_type_tree)
+ || !cp_parser_require (parser, CPP_COLON, RT_COLON))
{
if (prefer_type_tree == error_mark_node)
return error_mark_node;
@@ -43179,6 +43170,10 @@ cp_parser_omp_clause_init (cp_parser *parser, tree list)
return list;
}
+ if (!target && !targetsync)
+ error_at (loc,
+ "missing required %<target%> and/or %<targetsync%> modifier");
+
tree nl = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_INIT, list,
NULL, false);
for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
@@ -50578,6 +50573,10 @@ cp_finish_omp_declare_variant (cp_parser *parser, cp_token *pragma_tok,
&targetsync,
&prefer_type_tree))
goto fail;
+ if (!target && !targetsync)
+ error_at (loc,
+ "missing required %<target%> and/or "
+ "%<targetsync%> modifier");
tree t = build_tree_list (target ? boolean_true_node
: boolean_false_node,
targetsync ? boolean_true_node