aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-09-12 22:38:34 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-09-12 22:38:34 +0000
commit6f25cb3578f72310c50d4ea2d89179e169beec31 (patch)
treeef9919c9c5b79ac00d1c64401535d51148119164 /gcc
parentb35c082263257779ba2c3e2ae8fbeaa19bfdf374 (diff)
downloadgcc-6f25cb3578f72310c50d4ea2d89179e169beec31.zip
gcc-6f25cb3578f72310c50d4ea2d89179e169beec31.tar.gz
gcc-6f25cb3578f72310c50d4ea2d89179e169beec31.tar.bz2
re PR c++/23789 (compilation error when template parameters have certain complexity)
PR c++/23789 * cvt.c (perform_qualification_conversions): Don't create unnecessary NOP_EXPRs. * pt.c (tsubst_template_arg): Use fold_non_dependent_expr. PR c++/23789 * g++.dg/template/nontype14.C: New test. From-SVN: r104193
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/cvt.c6
-rw-r--r--gcc/cp/pt.c27
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/nontype14.C13
5 files changed, 30 insertions, 28 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b0f70bc..6ce6f5f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2005-09-12 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/23789
+ * cvt.c (perform_qualification_conversions): Don't create
+ unnecessary NOP_EXPRs.
+ * pt.c (tsubst_template_arg): Use fold_non_dependent_expr.
+
2005-09-12 Ian Lance Taylor <ian@airs.com>
PR g++/7874
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index de0792a..ac24e0a 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -1209,8 +1209,10 @@ perform_qualification_conversions (tree type, tree expr)
expr_type = TREE_TYPE (expr);
- if (TYPE_PTR_P (type) && TYPE_PTR_P (expr_type)
- && comp_ptr_ttypes (TREE_TYPE (type), TREE_TYPE (expr_type)))
+ if (same_type_p (type, expr_type))
+ return expr;
+ else if (TYPE_PTR_P (type) && TYPE_PTR_P (expr_type)
+ && comp_ptr_ttypes (TREE_TYPE (type), TREE_TYPE (expr_type)))
return build_nop (type, expr);
else if (TYPE_PTR_TO_MEMBER_P (type)
&& TYPE_PTR_TO_MEMBER_P (expr_type)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3f74955..07054ec 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5919,32 +5919,7 @@ tsubst_template_arg (tree t, tree args, tsubst_flags_t complain, tree in_decl)
else
{
r = tsubst_expr (t, args, complain, in_decl);
-
- if (!uses_template_parms (r))
- {
- /* Sometimes, one of the args was an expression involving a
- template constant parameter, like N - 1. Now that we've
- tsubst'd, we might have something like 2 - 1. This will
- confuse lookup_template_class, so we do constant folding
- here. We have to unset processing_template_decl, to fool
- tsubst_copy_and_build() into building an actual tree. */
-
- /* If the TREE_TYPE of ARG is not NULL_TREE, ARG is already
- as simple as it's going to get, and trying to reprocess
- the trees will break. Once tsubst_expr et al DTRT for
- non-dependent exprs, this code can go away, as the type
- will always be set. */
- if (!TREE_TYPE (r))
- {
- int saved_processing_template_decl = processing_template_decl;
- processing_template_decl = 0;
- r = tsubst_copy_and_build (r, /*args=*/NULL_TREE,
- tf_error, /*in_decl=*/NULL_TREE,
- /*function_p=*/false);
- processing_template_decl = saved_processing_template_decl;
- r = fold (r);
- }
- }
+ r = fold_non_dependent_expr (r);
}
return r;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cdea80a..9678760 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-09-12 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/23789
+ * g++.dg/template/nontype14.C: New test.
+
2005-09-12 Ian Lance Taylor <ian@airs.com>
PR g++/7874
diff --git a/gcc/testsuite/g++.dg/template/nontype14.C b/gcc/testsuite/g++.dg/template/nontype14.C
new file mode 100644
index 0000000..93338512
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nontype14.C
@@ -0,0 +1,13 @@
+// PR c++/23789
+
+template <int W> struct X {
+ template <int W2>
+ X< (W+(W&&W) > 1 ? W+(W&&W) : 1)+1>
+ operator + (const X<W2>&) const;
+};
+
+template <int dummy> void foo()
+{
+ X<6> A,B;
+ A + B;
+}