aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>2006-11-13 17:48:28 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2006-11-13 17:48:28 +0000
commita2c5ed873e291b1201311fc421b30f1f18bf125c (patch)
tree21a091cc74562e80f608497635a19c1e38b0e4fd
parentf4c0a30368a46ab95f266646085ac4d65c61725d (diff)
downloadgcc-a2c5ed873e291b1201311fc421b30f1f18bf125c.zip
gcc-a2c5ed873e291b1201311fc421b30f1f18bf125c.tar.gz
gcc-a2c5ed873e291b1201311fc421b30f1f18bf125c.tar.bz2
re PR c++/29518 (rejects valid template argument, enums vs templates)
PR c++/29518 * pt.c (coerce_template_parms): Do not skip_evaluation while substituting template arguments. PR c++/29518 * g++.dg/template/static28.C: New test. From-SVN: r118767
-rw-r--r--gcc/cp/pt.c7
-rw-r--r--gcc/testsuite/g++.dg/template/static28.C15
2 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9a46264..16e3e18 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4131,6 +4131,7 @@ coerce_template_parms (tree parms,
tree inner_args;
tree new_args;
tree new_inner_args;
+ bool saved_skip_evaluation;
inner_args = INNERMOST_TEMPLATE_ARGS (args);
nargs = inner_args ? NUM_TMPL_ARGS (inner_args) : 0;
@@ -4155,6 +4156,10 @@ coerce_template_parms (tree parms,
return error_mark_node;
}
+ /* We need to evaluate the template arguments, even though this
+ template-id may be nested within a "sizeof". */
+ saved_skip_evaluation = skip_evaluation;
+ skip_evaluation = false;
new_inner_args = make_tree_vec (nparms);
new_args = add_outermost_template_args (args, new_inner_args);
for (i = 0; i < nparms; i++)
@@ -4196,6 +4201,7 @@ coerce_template_parms (tree parms,
lost++;
TREE_VEC_ELT (new_inner_args, i) = arg;
}
+ skip_evaluation = saved_skip_evaluation;
if (lost)
return error_mark_node;
@@ -7261,7 +7267,6 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
max = tsubst_expr (omax, args, complain, in_decl,
/*integral_constant_expression_p=*/false);
- max = fold_non_dependent_expr (max);
max = fold_decl_constant_value (max);
if (TREE_CODE (max) != INTEGER_CST
diff --git a/gcc/testsuite/g++.dg/template/static28.C b/gcc/testsuite/g++.dg/template/static28.C
new file mode 100644
index 0000000..eb5ec53
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/static28.C
@@ -0,0 +1,15 @@
+// PR c++/29518
+
+template< bool C > int assertion_failed( int);
+template< class >
+struct N
+{
+ static bool const okay = true;
+ enum {
+ t = sizeof( assertion_failed<okay>( 0))
+ };
+};
+int main()
+{
+ N<int> n;
+}