From: Jason Merrill Date: Tue, 27 Jul 2010 22:06:03 +0000 (-0400) Subject: pt.c (tsubst_expr): Handle getting an AGGR_INIT_EXPR from build_value_init. X-Git-Tag: releases/gcc-4.6.0~5374 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=462aa169acee3e6dcfad17165aa7fc68ad417409;p=thirdparty%2Fgcc.git pt.c (tsubst_expr): Handle getting an AGGR_INIT_EXPR from build_value_init. * 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 35416869926a..362502126cbc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2010-07-27 Jason Merrill + + * 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 * cp-objcp-common.h (LANG_HOOKS_MISSING_ARGUMENT): Remove. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d796fd0822c0..0edb8004618f 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7a331479d8b5..2777ab790652 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 68b51d85a758..7a1a1759bab2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-27 Jason Merrill + + * g++.dg/cpp0x/variadic102.C: New. + * g++.dg/cpp0x/variadic103.C: New. + 2010-07-27 Maxim Kuvyrkov 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 index 000000000000..dc9c4aea8cb5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic102.C @@ -0,0 +1,19 @@ +// { dg-options "-std=c++0x" } + +struct nAny { + template + nAny(T&&...); +}; + +template +T&& create(); + +template +void test() { + T t(create()...); + (void) t; +} + +int main() { + test(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic103.C b/gcc/testsuite/g++.dg/cpp0x/variadic103.C new file mode 100644 index 000000000000..6d12331d000d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic103.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } + +template +T&& create(); + +template +void test() { + T t(create()...); // { dg-error "unknown bound" } + (void) t; +} + +int main() { + test(); +}