aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2008-01-12 22:39:49 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-01-12 22:39:49 +0000
commit52ef2874d251e7aafa267b9eaf9d5c6b24d29f4b (patch)
tree9fbe6956653b449d127488655bf8fc317363e50d /gcc/fold-const.c
parenta60b56a48842de242a7d71cb32bcf5b9e0482e4a (diff)
downloadgcc-52ef2874d251e7aafa267b9eaf9d5c6b24d29f4b.zip
gcc-52ef2874d251e7aafa267b9eaf9d5c6b24d29f4b.tar.gz
gcc-52ef2874d251e7aafa267b9eaf9d5c6b24d29f4b.tar.bz2
re PR ada/33788 (GNAT bug box in expand_expr_addr_expr_1, at expr.c:6862)
PR ada/33788 * fold-const.c (fold_unary) <VIEW_CONVERT_EXPR>: Fold an existing NOP_EXPR if it is between integral types with the same precision. From-SVN: r131493
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 8519e68..22350b9 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8247,7 +8247,12 @@ fold_unary (enum tree_code code, tree type, tree op0)
case VIEW_CONVERT_EXPR:
if (TREE_TYPE (op0) == type)
return op0;
- if (TREE_CODE (op0) == VIEW_CONVERT_EXPR)
+ if (TREE_CODE (op0) == VIEW_CONVERT_EXPR
+ || (TREE_CODE (op0) == NOP_EXPR
+ && INTEGRAL_TYPE_P (TREE_TYPE (op0))
+ && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0)))
+ && TYPE_PRECISION (TREE_TYPE (op0))
+ == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))))
return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0));
return fold_view_convert_expr (type, op0);