diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4f38a6df366f..858510d06cc5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-01-31 Jason Merrill + PR c++/58672 + * decl2.c (handle_tls_init): Handle null init fn. + PR c++/55800 * decl2.c (get_tls_init_fn): Copy DECL_EXTERNAL from the variable. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 22165915b924..35707a041a1b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4036,6 +4036,8 @@ handle_tls_init (void) if (TREE_PUBLIC (var)) { tree single_init_fn = get_tls_init_fn (var); + if (single_init_fn == NULL_TREE) + continue; cgraph_node *alias = cgraph_same_body_alias (cgraph_get_create_node (fn), single_init_fn, fn); diff --git a/gcc/testsuite/g++.dg/tls/thread_local-ice2.C b/gcc/testsuite/g++.dg/tls/thread_local-ice2.C new file mode 100644 index 000000000000..53bc2978093d --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/thread_local-ice2.C @@ -0,0 +1,11 @@ +// PR c++/58672 +// { dg-options "-std=c++11" } +// { dg-require-effective-target tls } + +struct A +{ + A(int); + i; // { dg-error "" } +}; + +thread_local A a(0);