aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-03-09 12:57:13 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-03-09 12:57:13 +0000
commit974b30f0ae978dc9c3c5f7d0cef914f99d8c48d5 (patch)
tree17f4d1e354cce34373329a5aa3eb5ccf2b29f82d /gcc/cp
parente2b8bd6cd8790cf7ef04a2437e9b58b311bfd64a (diff)
downloadgcc-974b30f0ae978dc9c3c5f7d0cef914f99d8c48d5.zip
gcc-974b30f0ae978dc9c3c5f7d0cef914f99d8c48d5.tar.gz
gcc-974b30f0ae978dc9c3c5f7d0cef914f99d8c48d5.tar.bz2
re PR c++/20186 (ICE with static_cast and type dependent variable (templates))
cp: PR c++/20186 * pt.c (contains_dependent_cast_p): New. (fold_non_dependent_expr): Call it. testsuite: PR c++/20186 * g++.dg/template/non-dependent12.C: New. From-SVN: r96190
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c49
2 files changed, 54 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a5dba31..8eec196 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2005-03-08 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/20186
+ * pt.c (contains_dependent_cast_p): New.
+ (fold_non_dependent_expr): Call it.
+
2005-03-08 Mark Mitchell <mark@codesourcery.com>
PR c++/20142
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 14940b7..320cd84 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3258,6 +3258,52 @@ redeclare_class_template (tree type, tree parms)
}
}
+/* Return true if non-dependent expressions EXPR contains within it a
+ cast expression with a dependent argument. */
+
+static bool
+contains_dependent_cast_p (tree expr)
+{
+ switch (TREE_CODE (expr))
+ {
+ case CAST_EXPR:
+ case REINTERPRET_CAST_EXPR:
+ case STATIC_CAST_EXPR:
+ case DYNAMIC_CAST_EXPR:
+ case CONST_CAST_EXPR:
+ {
+ tree op = TREE_OPERAND (expr, 0);
+
+ if (op && (type_dependent_expression_p (op)
+ || value_dependent_expression_p (op)))
+ return true;
+ }
+ break;
+
+ case TREE_LIST:
+ /* The operands of a CALL_EXPR are held as a list. */
+ for (; expr; expr = TREE_CHAIN (expr))
+ if (contains_dependent_cast_p (TREE_VALUE (expr)))
+ return true;
+ return false;
+
+ default:
+ break;
+ }
+
+ if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
+ {
+ int ix;
+
+ for (ix = TREE_CODE_LENGTH (TREE_CODE (expr)); ix--;)
+ if (TREE_OPERAND (expr, ix)
+ && contains_dependent_cast_p (TREE_OPERAND (expr, ix)))
+ return true;
+ }
+
+ return false;
+}
+
/* Simplify EXPR if it is a non-dependent expression. Returns the
(possibly simplified) expression. */
@@ -3273,7 +3319,8 @@ fold_non_dependent_expr (tree expr)
as two declarations of the same function, for example. */
if (processing_template_decl
&& !type_dependent_expression_p (expr)
- && !value_dependent_expression_p (expr))
+ && !value_dependent_expression_p (expr)
+ && !contains_dependent_cast_p (expr))
{
HOST_WIDE_INT saved_processing_template_decl;