diff options
author | Andrew Pinski <pinskia@physics.uc.edu> | 2006-01-23 14:56:45 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2006-01-23 06:56:45 -0800 |
commit | bac9efeaebb5cb047d731cf8a0590c69f83b4842 (patch) | |
tree | 711dff16c947cdd28322b754bcd859f81158a7fd /gcc/fold-const.c | |
parent | c685878451ba47834d3e1730bfaa95a8baccba95 (diff) | |
download | gcc-bac9efeaebb5cb047d731cf8a0590c69f83b4842.zip gcc-bac9efeaebb5cb047d731cf8a0590c69f83b4842.tar.gz gcc-bac9efeaebb5cb047d731cf8a0590c69f83b4842.tar.bz2 |
re PR middle-end/24437 (OBJ_TYPE_REF handling in fold_stmt should be moved to fold)
2006-01-23 Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/24437
* tree-ssa-ccp.c (fold_stmt): Move folding of OBJ_TYPE_REF
with a call expr to ...
* fold-const.c (fold_ternary) <case CALL_EXPR>: Here.
From-SVN: r110116
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 2b71ef3..ed100ce 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10295,6 +10295,26 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) && TREE_CODE (TREE_OPERAND (op0, 0)) == FUNCTION_DECL && DECL_BUILT_IN (TREE_OPERAND (op0, 0))) return fold_builtin (TREE_OPERAND (op0, 0), op1, false); + /* Check for resolvable OBJ_TYPE_REF. The only sorts we can resolve + here are when we've propagated the address of a decl into the + object slot. */ + if (TREE_CODE (op0) == OBJ_TYPE_REF + && lang_hooks.fold_obj_type_ref + && TREE_CODE (OBJ_TYPE_REF_OBJECT (op0)) == ADDR_EXPR + && DECL_P (TREE_OPERAND (OBJ_TYPE_REF_OBJECT (op0), 0))) + { + tree t; + + /* ??? Caution: Broken ADDR_EXPR semantics means that + looking at the type of the operand of the addr_expr + can yield an array type. See silly exception in + check_pointer_types_r. */ + + t = TREE_TYPE (TREE_TYPE (OBJ_TYPE_REF_OBJECT (op0))); + t = lang_hooks.fold_obj_type_ref (op0, t); + if (t) + return fold_build3 (code, type, t, op1, op2); + } return NULL_TREE; case BIT_FIELD_REF: |