From 22531fb1957ca61debd68c6d3bbc16899b907ba8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 23 Oct 2012 20:04:55 +0200 Subject: [PATCH] re PR c++/54844 (ice tsubst_copy, at cp/pt.c:12352) PR c++/54844 * pt.c (tsubst_copy, tsubst_copy_and_build) : Use tsubst instead of tsubst_copy* on types. * g++.dg/template/sizeof14.C: New test. From-SVN: r192736 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 15 +++++++++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/sizeof14.C | 4 ++++ 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/sizeof14.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bb06612e1549..1cad7963182f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-10-23 Jakub Jelinek + PR c++/54844 + * pt.c (tsubst_copy, tsubst_copy_and_build) : Use + tsubst instead of tsubst_copy* on types. + PR c++/54988 * decl2.c (cplus_decl_attributes): Don't return early if attributes is NULL. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7e8d8b0880d7..1ff1c73b90d7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12104,8 +12104,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) } if (SIZEOF_EXPR_TYPE_P (t)) { - r = tsubst_copy (TREE_TYPE (TREE_OPERAND (t, 0)), - args, complain, in_decl); + r = tsubst (TREE_TYPE (TREE_OPERAND (t, 0)), + args, complain, in_decl); r = build1 (NOP_EXPR, r, error_mark_node); r = build1 (SIZEOF_EXPR, tsubst (TREE_TYPE (t), args, complain, in_decl), r); @@ -13533,10 +13533,13 @@ tsubst_copy_and_build (tree t, { ++cp_unevaluated_operand; ++c_inhibit_evaluation_warnings; - op1 = tsubst_copy_and_build (op1, args, complain, in_decl, - /*function_p=*/false, - /*integral_constant_expression_p=*/ - false); + if (TYPE_P (op1)) + op1 = tsubst (op1, args, complain, in_decl); + else + op1 = tsubst_copy_and_build (op1, args, complain, in_decl, + /*function_p=*/false, + /*integral_constant_expression_p=*/ + false); --cp_unevaluated_operand; --c_inhibit_evaluation_warnings; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0779858f6ea2..8267df660e07 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-10-23 Jakub Jelinek + + PR c++/54844 + * g++.dg/template/sizeof14.C: New test. + 2012-10-23 Ian Bolton Jim MacArthur Chris Schlumberger-Socha diff --git a/gcc/testsuite/g++.dg/template/sizeof14.C b/gcc/testsuite/g++.dg/template/sizeof14.C new file mode 100644 index 000000000000..8f402046591c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof14.C @@ -0,0 +1,4 @@ +// PR c++/54844 +// { dg-do compile } +template int fn () { return sizeof (double); } +int var = fn <0> (); -- 2.47.2