aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-10-20 08:38:58 +0200
committerJakub Jelinek <jakub@redhat.com>2021-10-20 08:38:58 +0200
commit424945258d1778617b5d3d5273f6e1c10e718f80 (patch)
tree99a26d12e244655ae21bb66b3caee304dcf08411 /gcc/cp/parser.c
parentd8edfadfc7a9795b65177a50ce44fd348858e844 (diff)
downloadgcc-424945258d1778617b5d3d5273f6e1c10e718f80.zip
gcc-424945258d1778617b5d3d5273f6e1c10e718f80.tar.gz
gcc-424945258d1778617b5d3d5273f6e1c10e718f80.tar.bz2
c++: Fix up push_local_extern_decl_alias error recovery [PR102642]
My recent push_local_extern_decl_alias change broke error-recovery, do_pushdecl can return error_mark_node and set_decl_tls_model can't be called on that. There are other code paths that store error_mark_node into DECL_LOCAL_DECL_ALIAS, with the intent to differentiate the cases where we haven't yet tried to push it into the namespace scope (NULL) and one where we have tried it but it failed (error_mark_node), but looking around, there are other spots where we call functions or do processing which doesn't tolerate error_mark_node. So, the first hunk with the testcase fixes the testcase, the others fix what I've spotted and the fix was easy to figure out (there are I think 3 other spots mainly for function multiversioning). 2021-10-20 Jakub Jelinek <jakub@redhat.com> PR c++/102642 * name-lookup.c (push_local_extern_decl_alias): Don't call set_decl_tls_model on error_mark_node. * decl.c (make_rtl_for_nonlocal_decl): Don't call set_user_assembler_name on error_mark_node. * parser.c (cp_parser_oacc_declare): Ignore DECL_LOCAL_DECL_ALIAS if it is error_mark_node. (cp_parser_omp_declare_target): Likewise. * g++.dg/tls/pr102642.C: New test.
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 865778e..9c7ed65 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -44437,7 +44437,8 @@ cp_parser_oacc_declare (cp_parser *parser, cp_token *pragma_tok)
dependent local extern variable decls are as rare as
hen's teeth. */
if (auto alias = DECL_LOCAL_DECL_ALIAS (decl))
- decl = alias;
+ if (alias != error_mark_node)
+ decl = alias;
if (OMP_CLAUSE_MAP_KIND (t) == GOMP_MAP_LINK)
id = get_identifier ("omp declare target link");
@@ -45665,7 +45666,8 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok)
if (VAR_OR_FUNCTION_DECL_P (t)
&& DECL_LOCAL_DECL_P (t)
&& DECL_LANG_SPECIFIC (t)
- && DECL_LOCAL_DECL_ALIAS (t))
+ && DECL_LOCAL_DECL_ALIAS (t)
+ && DECL_LOCAL_DECL_ALIAS (t) != error_mark_node)
handle_omp_declare_target_clause (c, DECL_LOCAL_DECL_ALIAS (t),
device_type);
}