re PR c/5656 (ICE in emit_move_insn, at expr.c:2748, regression from gcc 3.0)
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Mar 2002 08:47:14 +0000 (09:47 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Mar 2002 08:47:14 +0000 (09:47 +0100)
PR c/5656
* langhooks.h (struct lang_hooks_for_tree_inlining): Add
convert_parm_for_inlining.
* c-lang.c (LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING):
Define.
* langhooks-def.h: Likewise.
* objc/objc-lang.c: Likewise.
* langhooks.c (lhd_tree_inlining_convert_parm_for_inlining): New
function.
* tree-inline.c (initialize_inlined_parameters):
Call convert_parm_for_inlining lang hook if needed.
* c-typeck.c (c_convert_parm_for_inlining): New function.
* c-tree.h (c_convert_parm_for_inlining): Add prototype.

* gcc.c-torture/compile/20020318-1.c: New test.

From-SVN: r51025

gcc/ChangeLog
gcc/c-lang.c
gcc/c-tree.h
gcc/c-typeck.c
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h
gcc/objc/objc-lang.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20020318-1.c [new file with mode: 0644]
gcc/tree-inline.c

index ecaedd0dec5a4e8d1014721389cb7b50dd349f42..795c75f1932a12bafc710e480bc57f73c5877684 100644 (file)
@@ -1,3 +1,19 @@
+2002-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/5656
+       * langhooks.h (struct lang_hooks_for_tree_inlining): Add
+       convert_parm_for_inlining.
+       * c-lang.c (LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING):
+       Define.
+       * langhooks-def.h: Likewise.
+       * objc/objc-lang.c: Likewise.
+       * langhooks.c (lhd_tree_inlining_convert_parm_for_inlining): New
+       function.
+       * tree-inline.c (initialize_inlined_parameters):
+       Call convert_parm_for_inlining lang hook if needed.
+       * c-typeck.c (c_convert_parm_for_inlining): New function.
+       * c-tree.h (c_convert_parm_for_inlining): Add prototype.
+
 2002-03-18  Mark Mitchell  <mark@codesourcery.com>
 
        * calls.c (precompute_arguments): Do not assume that temporaries 
index bb26001f18571a40fb900746b5d0d5458cbbf582..325ebd5d15d6bb16d064dba34146b5322d9f90b6 100644 (file)
@@ -70,6 +70,9 @@ static void c_post_options PARAMS ((void));
 #undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
 #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \
   anon_aggr_type_p
+#undef LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING
+#define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
+  c_convert_parm_for_inlining
 
 /* ### When changing hooks, consider if ObjC needs changing too!! ### */
 
index d39e3ff6e8369b73525da148bafd5c8a89380e2c..f01b5238d0e033a6024c196f721374133d517dd7 100644 (file)
@@ -270,6 +270,7 @@ extern void c_finish_case                       PARAMS ((void));
 extern tree simple_asm_stmt                    PARAMS ((tree));
 extern tree build_asm_stmt                     PARAMS ((tree, tree, tree,
                                                         tree, tree));
+extern tree c_convert_parm_for_inlining                PARAMS ((tree, tree, tree));
 
 /* Set to 0 at beginning of a function definition, set to 1 if
    a return statement that specifies a return value is seen.  */
index b28466122fa04a34e990f33686f630ed4090ebcb..1772557449c4ffb400faaa3a1bb27ab25b82ebfa 100644 (file)
@@ -4259,6 +4259,30 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
   return error_mark_node;
 }
 
+/* Convert VALUE for assignment into inlined parameter PARM.  */
+
+tree
+c_convert_parm_for_inlining (parm, value, fn)
+     tree parm, value, fn;
+{
+  tree ret, type;
+
+  /* If FN was prototyped, the value has been converted already
+     in convert_arguments.  */
+  if (! value || TYPE_ARG_TYPES (TREE_TYPE (fn)))
+    return value;
+
+  type = TREE_TYPE (parm);
+  ret = convert_for_assignment (type, value, 
+                               (char *) 0 /* arg passing  */, fn,
+                               DECL_NAME (fn), 0);
+  if (PROMOTE_PROTOTYPES
+      && INTEGRAL_TYPE_P (type)
+      && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
+    ret = default_conversion (ret);
+  return ret;
+}
+
 /* Print a warning using MSGID.
    It gets OPNAME as its one parameter.
    If OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'".
index ffc86d3958e75b1fcb7b81b2c07661695cbfbcdc..abd28471f8ffbde78a29f397cd2f3443c4e94b49 100644 (file)
@@ -63,6 +63,7 @@ tree lhd_tree_inlining_copy_res_decl_for_inlining PARAMS ((tree, tree,
 int lhd_tree_inlining_anon_aggr_type_p         PARAMS ((tree));
 int lhd_tree_inlining_start_inlining           PARAMS ((tree));
 void lhd_tree_inlining_end_inlining            PARAMS ((tree));
+tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree));
 
 #define LANG_HOOKS_NAME                        "GNU unknown"
 #define LANG_HOOKS_IDENTIFIER_SIZE     sizeof (struct lang_identifier)
@@ -107,6 +108,8 @@ void lhd_tree_inlining_end_inlining         PARAMS ((tree));
   lhd_tree_inlining_start_inlining
 #define LANG_HOOKS_TREE_INLINING_END_INLINING \
   lhd_tree_inlining_end_inlining
+#define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
+  lhd_tree_inlining_convert_parm_for_inlining
 
 #define LANG_HOOKS_TREE_INLINING_INITIALIZER { \
   LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \
@@ -118,7 +121,8 @@ void lhd_tree_inlining_end_inlining         PARAMS ((tree));
   LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING, \
   LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P, \
   LANG_HOOKS_TREE_INLINING_START_INLINING, \
-  LANG_HOOKS_TREE_INLINING_END_INLINING \
+  LANG_HOOKS_TREE_INLINING_END_INLINING, \
+  LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
 } \
 
 /* Tree dump hooks.  */
index a976d748029b3d755d64b3d82a2d6e68c2a0c179..6be5304a3285777d3e1ce9a076e02e62ed243fb8 100644 (file)
@@ -277,6 +277,18 @@ lhd_tree_inlining_end_inlining (fn)
 {
 }
 
+/* lang_hooks.tree_inlining.convert_parm_for_inlining performs any
+   language-specific conversion before assigning VALUE to PARM.  */
+
+tree
+lhd_tree_inlining_convert_parm_for_inlining (parm, value, fndecl)
+     tree parm ATTRIBUTE_UNUSED;
+     tree value;
+     tree fndecl ATTRIBUTE_UNUSED;
+{
+  return value;
+}
+
 /* lang_hooks.tree_dump.dump_tree:  Dump language-specific parts of tree 
    nodes.  Returns non-zero if it does not want the usual dumping of the 
    second argument.  */
index c7e43ce63f7d14140691276a6f550050965efb69..902bb55bc8c9bfdf64ea9372122b8bd090014ca9 100644 (file)
@@ -48,6 +48,9 @@ struct lang_hooks_for_tree_inlining
   int (*anon_aggr_type_p) PARAMS ((union tree_node *));
   int (*start_inlining) PARAMS ((union tree_node *));
   void (*end_inlining) PARAMS ((union tree_node *));
+  union tree_node *(*convert_parm_for_inlining) PARAMS ((union tree_node *,
+                                                        union tree_node *,
+                                                        union tree_node *));
 };
 
 /* The following hooks are used by tree-dump.c.  */
index 8f1a68bbfcfc49b3d0349ee6fdedc9726ac6a8f8..d779e69d24703ca734690922c33c4077496945e7 100644 (file)
@@ -64,6 +64,9 @@ static void objc_post_options                   PARAMS ((void));
 #undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
 #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \
   anon_aggr_type_p
+#undef LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING
+#define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
+  c_convert_parm_for_inlining
 
 /* Each front end provides its own hooks, for toplev.c.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
index c25a2f43d5068838a0be676fccfa090df477178e..f5cd64c333bc0071321c3a96626b8fbb1225c5a7 100644 (file)
@@ -1,3 +1,7 @@
+2002-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.c-torture/compile/20020318-1.c: New test.
+
 2002-03-18  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/opt/conj1.C: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020318-1.c b/gcc/testsuite/gcc.c-torture/compile/20020318-1.c
new file mode 100644 (file)
index 0000000..097a35d
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR c/5656
+   This testcase ICEd on IA-32 at -O3, due to tree inliner not converting
+   parameter assignment when using K&R syntax.  */
+
+void foo (c)
+     char c;
+{
+  (void) &c;
+}
+
+int bar (void);
+
+void baz (void)
+{
+  foo (bar ());
+}
index ce548849d2d14bb2b37f526e371f1bab6885748f..831f6019c7b3fc70155fd3289ecef9e9e049f3ad 100644 (file)
@@ -483,7 +483,8 @@ initialize_inlined_parameters (id, args, fn)
       tree cleanup;
 
       /* Find the initializer.  */
-      value = a ? TREE_VALUE (a) : NULL_TREE;
+      value = (*lang_hooks.tree_inlining.convert_parm_for_inlining)
+             (p, a ? TREE_VALUE (a) : NULL_TREE, fn);
 
       /* If the parameter is never assigned to, we may not need to
         create a new variable here at all.  Instead, we may be able