2007-06-27 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jun 2007 14:01:27 +0000 (14:01 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jun 2007 14:01:27 +0000 (14:01 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126054 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/inline-22.c [new file with mode: 0644]
gcc/tree.h

index 321298c..2f148ac 100644 (file)
@@ -1,3 +1,11 @@
+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.
index e2d57c9..d806e7a 100644 (file)
@@ -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.  */
 
index 7f5615e..d935ec1 100644 (file)
@@ -2141,8 +2141,7 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
        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;
@@ -2155,8 +2154,7 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
        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;
index 006c1fa..9f350e7 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/gcc.dg/inline-22.c b/gcc/testsuite/gcc.dg/inline-22.c
new file mode 100644 (file)
index 0000000..6d790f9
--- /dev/null
@@ -0,0 +1,7 @@
+/* { 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); }
index 28169d7..942ab5f 100644 (file)
@@ -4444,6 +4444,7 @@ extern tree fold_build2_initializer (enum tree_code, tree, tree, tree);
 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);