From: Paolo Carlini Date: Wed, 14 Jan 2015 22:28:07 +0000 (+0000) Subject: re PR c++/58671 ([c++11] ICE with thread_local and self-referential variable initiali... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=36b218ee8f31c868d1370df090a9ddc0594b1ba0;p=gcc.git re PR c++/58671 ([c++11] ICE with thread_local and self-referential variable initialization) /cp 2015-01-14 Paolo Carlini PR c++/58671 * decl2.c (var_defined_without_dynamic_init): Handle gracefully self-initialization. /testsuite 2015-01-14 Paolo Carlini PR c++/58671 * g++.dg/tls/thread_local-ice3.C: New. From-SVN: r219621 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 013c432a661..02b4fac907b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-01-14 Paolo Carlini + + PR c++/58671 + * decl2.c (var_defined_without_dynamic_init): Handle gracefully + self-initialization. + 2015-01-13 Jason Merrill PR c++/64356 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index e59a8f9058d..a7bc08f6e56 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3094,8 +3094,11 @@ var_defined_without_dynamic_init (tree var) counts as dynamic initialization. */ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (var))) return false; - /* If it's in this TU, its initializer has been processed. */ - gcc_assert (DECL_INITIALIZED_P (var)); + /* If it's in this TU, its initializer has been processed, unless + it's a case of self-initialization, then DECL_INITIALIZED_P is + false while the initializer is handled by finish_id_expression. */ + if (!DECL_INITIALIZED_P (var)) + return false; /* If it has no initializer or a constant one, it's not dynamic. */ return (!DECL_NONTRIVIALLY_INITIALIZED_P (var) || DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (var)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 061aa7e0810..e58d7098f98 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-14 Paolo Carlini + + PR c++/58671 + * g++.dg/tls/thread_local-ice3.C: New. + 2015-01-14 H.J. Lu * gcc.target/i386/fentry-override.c: Properly place {} in target @@ -9,7 +14,6 @@ * gcc.dg/atomic-invalid.c: Check for invalid memory model warnings instead of errors. - 2015-01-14 Ilya Verbin * lib/target-supports.exp (check_effective_target_lto): Check for -flto @@ -64,7 +68,7 @@ PR lto/64415 * gcc.dg/lto/pr64415_0.c: New testcase. - * gcc.dg/lto/pr64415_1.c: Likewise. + * gcc.dg/lto/pr64415_1.c: Likewise. 2015-01-14 Martin Liska diff --git a/gcc/testsuite/g++.dg/tls/thread_local-ice3.C b/gcc/testsuite/g++.dg/tls/thread_local-ice3.C new file mode 100644 index 00000000000..d061a239f6c --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/thread_local-ice3.C @@ -0,0 +1,5 @@ +// PR c++/58671 +// { dg-do compile { target c++11 } } +// { dg-require-effective-target tls } + +thread_local int i = i;