diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f85f4b1619f..75c0c53dc8e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-11-10 Jason Merrill + PR c++/46420 + * pt.c (tsubst_copy_and_build) [TARGET_EXPR]: New case. + [CONSTRUCTOR]: Use the tsubsted type. + PR c++/46369 * semantics.c (cxx_eval_bit_field_ref): New. (cxx_eval_constant_expression): Call it. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7a06038c674..56b7543504c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13197,6 +13197,7 @@ tsubst_copy_and_build (tree t, if (TREE_HAS_CONSTRUCTOR (t)) return finish_compound_literal (type, r); + TREE_TYPE (r) = type; return r; } @@ -13316,6 +13317,12 @@ tsubst_copy_and_build (tree t, return build_lambda_object (r); } + case TARGET_EXPR: + /* We can get here for a constant initializer of non-dependent type. + FIXME stop folding in cp_parser_initializer_clause. */ + gcc_assert (TREE_CONSTANT (t)); + return get_target_expr (RECUR (TARGET_EXPR_INITIAL (t))); + default: /* Handle Objective-C++ constructs, if appropriate. */ { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1115512a2d3..467290d51b0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-11-10 Jason Merrill + + * g++.dg/cpp0x/constexpr-46420.C: New. + 2010-11-10 Joseph Myers * g++.dg/ext/bitfield2.C, g++.dg/ext/bitfield4.C, diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-46420.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-46420.C new file mode 100644 index 00000000000..757a6e315b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-46420.C @@ -0,0 +1,13 @@ +// PR c++/46420 +// { dg-options -std=c++0x } + +template class vector { }; +struct A{}; +template +void complete_test(vector data1){ + A drop=A(); +} +int main(){ + vector vect1; + complete_test(vect1); +}