This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/43143 (variadics, value-init and array)


Fixing a C++0x bug that came up recently on the committee core language reflector. This code is not going to be hit by non-C++0x input.

Tested x86_64-unknown-linux-gnu, applied to trunk.
commit 010eb8ba585dd4daf87c72f58adf35456afd147e
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 22 15:40:25 2010 -0500

    	PR c++/43143
    	* typeck2.c (digest_init_r): Accept value init of array.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 66ff3c1..7ec4374 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic100.C b/gcc/testsuite/g++.dg/cpp0x/variadic100.C
new file mode 100644
index 0000000..a364bbc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic100.C
@@ -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
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]