cp_parser_push_lexer_for_tokens (parser, cp);
parser->lexer->in_pragma = true;
}
- if (!cp_parser_omp_declare_reduction_exprs (fndecl, parser))
- {
- if (!block_scope)
- finish_function (/*inline_p=*/false);
- else
- DECL_CONTEXT (fndecl) = current_function_decl;
- if (cp)
- cp_parser_pop_lexer (parser);
- goto fail;
- }
+
+ bool ok = cp_parser_omp_declare_reduction_exprs (fndecl, parser);
+
if (cp)
cp_parser_pop_lexer (parser);
if (!block_scope)
else
{
DECL_CONTEXT (fndecl) = current_function_decl;
+ if (DECL_TEMPLATE_INFO (fndecl))
+ DECL_CONTEXT (DECL_TI_TEMPLATE (fndecl)) = current_function_decl;
+ }
+ if (!ok)
+ goto fail;
+
+ if (block_scope)
+ {
block = finish_omp_structured_block (block);
if (TREE_CODE (block) == BIND_EXPR)
DECL_SAVED_TREE (fndecl) = BIND_EXPR_BODY (block);
if (processing_template_decl)
add_decl_expr (fndecl);
}
+
cp_check_omp_declare_reduction (fndecl);
if (cp == NULL && types.length () > 1)
cp = cp_token_cache_new (first_token,
&& DECL_OMP_DECLARE_REDUCTION_P (decl)
&& DECL_FUNCTION_SCOPE_P (pattern_decl))
{
- DECL_CONTEXT (decl) = NULL_TREE;
+ /* We pretend this is regular local extern decl of
+ a namespace-scope fn. Then we make it really
+ local, it is a nested function. */
+ DECL_CONTEXT (decl) = global_namespace;
pushdecl (decl);
DECL_CONTEXT (decl) = current_function_decl;
cp_check_omp_declare_reduction (decl);
if (t == NULL_TREE || t == error_mark_node)
return;
- gcc_assert (TREE_CODE (t) == STATEMENT_LIST);
+ gcc_assert (TREE_CODE (t) == STATEMENT_LIST && current_function_decl);
tree_stmt_iterator tsi;
int i;
args, complain, in_decl);
tree omp_in = tsubst (DECL_EXPR_DECL (stmts[1]),
args, complain, in_decl);
+ /* tsubsting a local var_decl leaves DECL_CONTEXT null, as we
+ expect to be pushing it. */
DECL_CONTEXT (omp_out) = current_function_decl;
DECL_CONTEXT (omp_in) = current_function_decl;
keep_next_level (true);