aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-06-27 14:01:27 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-06-27 14:01:27 +0000
commit3b35764639e5ada3cb9af920e9c30d4ec0b6a104 (patch)
tree8bf61b8be7e8989d8c213faaeb4fb64ab0561c76 /gcc/fold-const.c
parent95e88efd101c43bb55c8584fa2bf2ccbff718401 (diff)
downloadgcc-3b35764639e5ada3cb9af920e9c30d4ec0b6a104.zip
gcc-3b35764639e5ada3cb9af920e9c30d4ec0b6a104.tar.gz
gcc-3b35764639e5ada3cb9af920e9c30d4ec0b6a104.tar.bz2
re PR middle-end/32492 (attribute always_inline -> sorry, unimplemented: recursive inlining)
2007-06-27 Richard Guenther <rguenther@suse.de> PR middle-end/32492 * tree.h (fold_convertible_p): Declare. * fold-const.c (fold_convertible_p): New function. * gimplify.c (gimplify_call_expr): Use fold_convertible_p instead of lang_hooks.types_compatible_p. * gcc.dg/inline-22.c: New testcase. From-SVN: r126054
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e2d57c9..d806e7a 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2211,6 +2211,40 @@ build_zero_vector (tree type)
return build_vector (type, list);
}
+/* Returns true, if ARG is convertible to TYPE using a NOP_EXPR. */
+
+bool
+fold_convertible_p (tree type, tree arg)
+{
+ tree orig = TREE_TYPE (arg);
+
+ if (type == orig)
+ return true;
+
+ if (TREE_CODE (arg) == ERROR_MARK
+ || TREE_CODE (type) == ERROR_MARK
+ || TREE_CODE (orig) == ERROR_MARK)
+ return false;
+
+ if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig))
+ return true;
+
+ switch (TREE_CODE (type))
+ {
+ case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
+ case POINTER_TYPE: case REFERENCE_TYPE:
+ case OFFSET_TYPE:
+ if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig)
+ || TREE_CODE (orig) == OFFSET_TYPE)
+ return true;
+ return (TREE_CODE (orig) == VECTOR_TYPE
+ && tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig)));
+
+ default:
+ return TREE_CODE (type) == TREE_CODE (orig);
+ }
+}
+
/* Convert expression ARG to type TYPE. Used by the middle-end for
simple conversions in preference to calling the front-end's convert. */