]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pt.c (tsubst_expr): Handle getting an AGGR_INIT_EXPR from build_value_init.
authorJason Merrill <jason@redhat.com>
Tue, 27 Jul 2010 22:06:03 +0000 (18:06 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 27 Jul 2010 22:06:03 +0000 (18:06 -0400)
* pt.c (tsubst_expr) [DECL_EXPR]: Handle getting an AGGR_INIT_EXPR
from build_value_init.
* init.c (build_value_init_noctor): Give error for unknown array
bound.

From-SVN: r162603

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic102.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/variadic103.C [new file with mode: 0644]

index 35416869926a656af0b42e02f1e09e164d1cbcc0..362502126cbce4117f62d2da9fe61d7896ac59f0 100644 (file)
@@ -1,3 +1,10 @@
+2010-07-27  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (tsubst_expr) [DECL_EXPR]: Handle getting an AGGR_INIT_EXPR
+       from build_value_init.
+       * init.c (build_value_init_noctor): Give error for unknown array
+       bound.
+
 2010-07-27  Joseph Myers  <joseph@codesourcery.com>
 
        * cp-objcp-common.h (LANG_HOOKS_MISSING_ARGUMENT): Remove.
index d796fd0822c00843be465085af2d404979d66c07..0edb8004618fcf67d2e7de759cc93bebc39e500a 100644 (file)
@@ -379,7 +379,10 @@ build_value_init_noctor (tree type)
       /* If we have an error_mark here, we should just return error mark
         as we don't know the size of the array yet.  */
       if (max_index == error_mark_node)
-       return error_mark_node;
+       {
+         error ("cannot value-initialize array of unknown bound %qT", type);
+         return error_mark_node;
+       }
       gcc_assert (TREE_CODE (max_index) == INTEGER_CST);
 
       /* A zero-sized array, which is accepted as an extension, will
index 7a331479d8b515bbe7e2aaf474c27a55a12d0554..2777ab790652f7043d9bf8a52740e06179f5f12a 100644 (file)
@@ -11697,14 +11697,18 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
                        tree t = RECUR (init);
 
                        if (init && !t)
-                         /* If we had an initializer but it
-                            instantiated to nothing,
-                            value-initialize the object.  This will
-                            only occur when the initializer was a
-                            pack expansion where the parameter packs
-                            used in that expansion were of length
-                            zero.  */
-                         init = build_value_init (TREE_TYPE (decl));
+                         {
+                           /* If we had an initializer but it
+                              instantiated to nothing,
+                              value-initialize the object.  This will
+                              only occur when the initializer was a
+                              pack expansion where the parameter packs
+                              used in that expansion were of length
+                              zero.  */
+                           init = build_value_init (TREE_TYPE (decl));
+                           if (TREE_CODE (init) == AGGR_INIT_EXPR)
+                             init = get_target_expr (init);
+                         }
                        else
                          init = t;
                      }
index 68b51d85a758b9b603094e27d1795e9f52382043..7a1a1759bab2af648208266da9fe7ed681267eba 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-27  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/variadic102.C: New.
+       * g++.dg/cpp0x/variadic103.C: New.
+
 2010-07-27  Maxim Kuvyrkov  <maxim@codesourcery.com>
 
        PR rtl-optimization/40956
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic102.C b/gcc/testsuite/g++.dg/cpp0x/variadic102.C
new file mode 100644 (file)
index 0000000..dc9c4ae
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-options "-std=c++0x" }
+
+struct nAny {
+  template<class... T>
+  nAny(T&&...);
+};
+
+template<class T>
+T&& create();
+
+template<class T, class... Args>
+void test() {
+  T t(create<Args>()...);
+  (void) t;
+}
+
+int main() {
+  test<nAny>();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic103.C b/gcc/testsuite/g++.dg/cpp0x/variadic103.C
new file mode 100644 (file)
index 0000000..6d12331
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-options "-std=c++0x" }
+
+template<class T>
+T&& create();
+
+template<class T, class... Args>
+void test() {
+  T t(create<Args>()...);      // { dg-error "unknown bound" }
+  (void) t;
+}
+
+int main() {
+  test<int[]>();
+}