re PR c++/58671 ([c++11] ICE with thread_local and self-referential variable initiali...
authorPaolo Carlini <paolo@gcc.gnu.org>
Wed, 14 Jan 2015 22:28:07 +0000 (22:28 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 14 Jan 2015 22:28:07 +0000 (22:28 +0000)
/cp
2015-01-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58671
* decl2.c (var_defined_without_dynamic_init): Handle gracefully
self-initialization.

/testsuite
2015-01-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58671
* g++.dg/tls/thread_local-ice3.C: New.

From-SVN: r219621

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tls/thread_local-ice3.C [new file with mode: 0644]

index 013c432a6618f64b269f61e392e80f526bd7377f..02b4fac907b7dd8b4464eb2b42918c6a45fc1ce6 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58671
+       * decl2.c (var_defined_without_dynamic_init): Handle gracefully
+       self-initialization.
+
 2015-01-13  Jason Merrill  <jason@redhat.com>
 
        PR c++/64356
index e59a8f9058dc3f568cabb8019dce39237134f743..a7bc08f6e56f4af532db0224b60a737e0bbab848 100644 (file)
@@ -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));
index 061aa7e0810b6b3e203108ba4282825e532d9b41..e58d7098f9814a79c025579cfef4c1b2d96de6c6 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58671
+       * g++.dg/tls/thread_local-ice3.C: New.
+
 2015-01-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        * 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  <ilya.verbin@intel.com>
 
        * 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  <mliska@suse.cz>
 
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 (file)
index 0000000..d061a23
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/58671
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target tls }
+
+thread_local int i = i;