re PR c++/55944 ([C++11] static local member with constexpr c'tor causes ICE)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 22 Jan 2013 23:38:34 +0000 (23:38 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 22 Jan 2013 23:38:34 +0000 (23:38 +0000)
/cp
2013-01-22  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/55944
* decl.c (check_initializer): Use TARGET_EXPR_DIRECT_INIT_P only
on TARGET_EXPR nodes.

/testsuite
2013-01-22  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/55944
* g++.dg/cpp0x/constexpr-static10.C: New.

From-SVN: r195391

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-static10.C [new file with mode: 0644]

index 7da2b4aa5694cbf5dc175f0b91e1c0b3e4926c97..9a25935adff127fbcd60739af544946efc80d66c 100644 (file)
@@ -1,3 +1,9 @@
+2013-01-22  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/55944
+       * decl.c (check_initializer): Use TARGET_EXPR_DIRECT_INIT_P only
+       on TARGET_EXPR nodes.
+
 2013-01-22  Jason Merrill  <jason@redhat.com>
 
        PR c++/56071
index 768573f7ed54ac601f6cbd9757c5346f8c1426fc..9b40018370fd5b2190782c9e16876379b6ffbf60 100644 (file)
@@ -5693,7 +5693,7 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
                       && (!init || TREE_CODE (init) == TREE_LIST))
                {
                  init = build_functional_cast (type, init, tf_none);
-                 if (init != error_mark_node)
+                 if (TREE_CODE (init) == TARGET_EXPR)
                    TARGET_EXPR_DIRECT_INIT_P (init) = true;
                }
              init_code = NULL_TREE;
index c0fe13bf0d1ac532e8d7c0995d293d6884b7d35d..6ed2b3e8904fff708a20e1c8d0a97693f77b6a5b 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-22  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/55944
+       * g++.dg/cpp0x/constexpr-static10.C: New.
+
 2013-01-22  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/56028
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static10.C
new file mode 100644 (file)
index 0000000..9b76e6f
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/55944
+// { dg-options -std=c++11 }
+
+template<class T>
+struct Test
+{
+  constexpr Test(T val) : value(val) {}
+  static void test()
+  {
+    static constexpr Test<int> x(42); // ICE
+  }
+  T value;
+};
+
+int main()
+{
+  static constexpr Test<int> x(42); // OK
+  Test<double>::test();
+}