public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4527] c++: Fix up push_local_extern_decl_alias error recovery [PR102642] Date: Wed, 20 Oct 2021 06:40:11 +0000 (GMT) [thread overview] Message-ID: <20211020064011.489CF3858C3A@sourceware.org> (raw) https://gcc.gnu.org/g:424945258d1778617b5d3d5273f6e1c10e718f80 commit r12-4527-g424945258d1778617b5d3d5273f6e1c10e718f80 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Oct 20 08:38:58 2021 +0200 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. Diff: --- gcc/cp/decl.c | 3 ++- gcc/cp/name-lookup.c | 4 +++- gcc/cp/parser.c | 6 ++++-- gcc/testsuite/g++.dg/tls/pr102642.C | 10 ++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 242429d9ef4..8a45411c995 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7373,7 +7373,8 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) This is horrible, as we're affecting a possibly-shared decl. Again, a one-true-decl model breaks down. */ - set_user_assembler_name (ns_decl, asmspec); + if (ns_decl != error_mark_node) + set_user_assembler_name (ns_decl, asmspec); } } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index c414a1091b4..035bcf51278 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3474,7 +3474,9 @@ push_local_extern_decl_alias (tree decl) push_nested_namespace (ns); alias = do_pushdecl (alias, /* hiding= */true); pop_nested_namespace (ns); - if (VAR_P (decl) && CP_DECL_THREAD_LOCAL_P (decl)) + if (VAR_P (decl) + && CP_DECL_THREAD_LOCAL_P (decl) + && alias != error_mark_node) set_decl_tls_model (alias, DECL_TLS_MODEL (decl)); } } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 865778e4d30..9c7ed65f55c 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); } diff --git a/gcc/testsuite/g++.dg/tls/pr102642.C b/gcc/testsuite/g++.dg/tls/pr102642.C new file mode 100644 index 00000000000..e3236d3dfdb --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/pr102642.C @@ -0,0 +1,10 @@ +// PR c++/102642 +// { dg-do compile { target c++11 } } + +thread_local int *z; // { dg-message "previous declaration" } + +void +foo () +{ + extern thread_local int z; // { dg-error "conflicting declaration" } +}
reply other threads:[~2021-10-20 6:40 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211020064011.489CF3858C3A@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).