+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.
+
2007-06-26 Jan Hubicka <jh@suse.cz>
* fwprop.c (try_fwprop_subst): Use validate_unshare_change.
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. */
if (!p
|| TREE_VALUE (p) == error_mark_node
|| CALL_EXPR_ARG (*expr_p, i) == error_mark_node
- || !lang_hooks.types_compatible_p
- (TREE_TYPE (CALL_EXPR_ARG (*expr_p, i)), TREE_VALUE (p)))
+ || !fold_convertible_p (TREE_VALUE (p), CALL_EXPR_ARG (*expr_p, i)))
{
CALL_CANNOT_INLINE_P (*expr_p) = 1;
break;
if (!p
|| p == error_mark_node
|| CALL_EXPR_ARG (*expr_p, i) == error_mark_node
- || !lang_hooks.types_compatible_p
- (TREE_TYPE (CALL_EXPR_ARG (*expr_p, i)), TREE_TYPE (p)))
+ || !fold_convertible_p (TREE_TYPE (p), CALL_EXPR_ARG (*expr_p, i)))
{
CALL_CANNOT_INLINE_P (*expr_p) = 1;
break;
+2007-06-27 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/32492
+ * gcc.dg/inline-22.c: New testcase.
+
2007-06-26 Hui-May Chang <hm.chang@apple.com>
* gcc.target/i386/large-size-array-3.c: Remove the larger size of
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-funit-at-a-time" } */
+/* Verify we can inline without a complete prototype and with promoted
+ arguments. See also PR32492. */
+__attribute__((always_inline)) void f1() {}
+__attribute__((always_inline)) void f2(char x) {}
+void f3() { f1(); f2(0); }
extern tree fold_build3_initializer (enum tree_code, tree, tree, tree, tree);
extern tree fold_build_call_array (tree, tree, int, tree *);
extern tree fold_build_call_array_initializer (tree, tree, int, tree *);
+extern bool fold_convertible_p (tree, tree);
extern tree fold_convert (tree, tree);
extern tree fold_single_bit_test (enum tree_code, tree, tree, tree);
extern tree fold_ignored_result (tree);