]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/61343 ([C++11] Missing default initialization for class with default constr...
authorJason Merrill <jason@redhat.com>
Thu, 5 Jun 2014 17:30:51 +0000 (13:30 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 5 Jun 2014 17:30:51 +0000 (13:30 -0400)
PR c++/61343
* decl.c (check_initializer): Maybe clear
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.

From-SVN: r211284

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/tls/thread_local9.C [new file with mode: 0644]

index fd51940758313b7246bf1ec2f49368823ea1dbf6..e9ea46d7d90bc518debb330ca35b5732f072d3a2 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/61343
+       * decl.c (check_initializer): Maybe clear
+       DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.
+
 2014-06-05  Richard Biener  <rguenther@suse.de>
 
        PR c++/61004
index 3d4058c2d9158dc4f554ee24e46b7cdd0554f602..b068df83cbf9f5edf9d92b6a771fd5e53b60f825 100644 (file)
@@ -5856,6 +5856,13 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
   if (init && init != error_mark_node)
     init_code = build2 (INIT_EXPR, type, decl, init);
 
+  if (init_code)
+    {
+      /* We might have set these in cp_finish_decl.  */
+      DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = false;
+      TREE_CONSTANT (decl) = false;
+    }
+
   if (init_code && DECL_IN_AGGR_P (decl))
     {
       static int explained = 0;
diff --git a/gcc/testsuite/g++.dg/tls/thread_local9.C b/gcc/testsuite/g++.dg/tls/thread_local9.C
new file mode 100644 (file)
index 0000000..c75528a
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/61343
+
+// { dg-do run { target c++11 } }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+
+struct Foo {
+  int value;
+
+  Foo() noexcept {
+    value = 12;
+  }
+};
+
+static thread_local Foo a{};
+
+static __attribute__((noinline)) void UseA() {
+  if (a.value != 12) __builtin_abort();
+}
+
+int main() {
+  UseA();
+}