gcc/gcc11-pr102642.patch
Jakub Jelinek 68a50d6964 11.2.1-4
2021-10-12 12:33:59 +02:00

48 lines
1.6 KiB
Diff

2021-10-11 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.
* parser.c (cp_parser_omp_declare_target): Likewise.
* g++.dg/tls/pr102642.C: New test.
--- gcc/cp/name-lookup.c.jj 2021-10-01 10:30:07.674588541 +0200
+++ gcc/cp/name-lookup.c 2021-10-11 12:43:39.261051228 +0200
@@ -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));
}
}
--- gcc/cp/parser.c.jj 2021-10-09 10:14:24.043098112 +0200
+++ gcc/cp/parser.c 2021-10-11 12:47:21.220874667 +0200
@@ -45665,7 +45666,8 @@ cp_parser_omp_declare_target (cp_parser
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);
}
--- gcc/testsuite/g++.dg/tls/pr102642.C.jj 2021-10-11 13:00:35.889503002 +0200
+++ gcc/testsuite/g++.dg/tls/pr102642.C 2021-10-11 13:00:20.388724721 +0200
@@ -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" }
+}