re PR c++/43143 ([c++0x] array value-initialization and variadics)
authorJason Merrill <jason@redhat.com>
Tue, 23 Feb 2010 18:32:20 +0000 (13:32 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 23 Feb 2010 18:32:20 +0000 (13:32 -0500)
PR c++/43143
* typeck2.c (digest_init_r): Accept value init of array.

From-SVN: r157015

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic100.C [new file with mode: 0644]

index a4a5cc2498d633452a1facad2380b7d22a6afabe..c72e7e3dc6b47d97ae6d4dd584d85a7648eaf7fd 100644 (file)
@@ -1,8 +1,12 @@
+2010-02-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/43143
+       * typeck2.c (digest_init_r): Accept value init of array.
+
 2010-02-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR c++/43126
        * typeck.c (convert_arguments): Update error message.
-       
 
 2010-02-22  Mike Stump  <mikestump@comcast.net>
 
index 66ff3c16264f4fa4d8507c3aef11dbd0bfbb1001..7ec4374a7095171da4ec9c37e88ce2259784b515 100644 (file)
@@ -929,10 +929,12 @@ digest_init_r (tree type, tree init, bool nested, int flags)
        }
 
       if (TREE_CODE (type) == ARRAY_TYPE
-         && TREE_CODE (init) != CONSTRUCTOR)
+         && !BRACE_ENCLOSED_INITIALIZER_P (init))
        {
-         /* Allow the result of build_array_copy.  */
-         if (TREE_CODE (init) == TARGET_EXPR
+         /* Allow the result of build_array_copy and of
+            build_value_init_noctor.  */
+         if ((TREE_CODE (init) == TARGET_EXPR
+              || TREE_CODE (init) == CONSTRUCTOR)
              && (same_type_ignoring_top_level_qualifiers_p
                  (type, TREE_TYPE (init))))
            return init;
index 7fe352009aa8719a4897b65c481c778d69ca44b3..5f9fdc03f38d0b0a8d689a79c0a7d6c63bfdfd1b 100644 (file)
@@ -1,3 +1,8 @@
+2010-02-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/43143
+       * g++.dg/cpp0x/variadic100.C: New.
+
 2010-02-23  Jason Merrill  <jason@redhat.com>
 
        PR debug/42800
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic100.C b/gcc/testsuite/g++.dg/cpp0x/variadic100.C
new file mode 100644 (file)
index 0000000..a364bbc
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/43143
+// { dg-options "-std=c++0x" }
+
+template<typename T>
+T&& declval();
+
+template<class T, class... Args>
+void test() {
+  T t(declval<Args>()...);
+}
+
+int main() {
+  test<const int>(); // OK
+  test<int[23]>(); // Error
+}