Commit f735a153 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/5656 (ICE in emit_move_insn, at expr.c:2748, regression from gcc 3.0)

	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
parent c1ea7843
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> 2002-03-18 Mark Mitchell <mark@codesourcery.com>
* calls.c (precompute_arguments): Do not assume that temporaries * calls.c (precompute_arguments): Do not assume that temporaries
......
...@@ -70,6 +70,9 @@ static void c_post_options PARAMS ((void)); ...@@ -70,6 +70,9 @@ static void c_post_options PARAMS ((void));
#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P #undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \ #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \
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!! ### */ /* ### When changing hooks, consider if ObjC needs changing too!! ### */
......
...@@ -270,6 +270,7 @@ extern void c_finish_case PARAMS ((void)); ...@@ -270,6 +270,7 @@ extern void c_finish_case PARAMS ((void));
extern tree simple_asm_stmt PARAMS ((tree)); extern tree simple_asm_stmt PARAMS ((tree));
extern tree build_asm_stmt PARAMS ((tree, tree, tree, extern tree build_asm_stmt PARAMS ((tree, tree, 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 /* Set to 0 at beginning of a function definition, set to 1 if
a return statement that specifies a return value is seen. */ a return statement that specifies a return value is seen. */
......
...@@ -4259,6 +4259,30 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) ...@@ -4259,6 +4259,30 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
return error_mark_node; 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. /* Print a warning using MSGID.
It gets OPNAME as its one parameter. It gets OPNAME as its one parameter.
If OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'". If OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'".
......
...@@ -63,6 +63,7 @@ tree lhd_tree_inlining_copy_res_decl_for_inlining PARAMS ((tree, tree, ...@@ -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_anon_aggr_type_p PARAMS ((tree));
int lhd_tree_inlining_start_inlining PARAMS ((tree)); int lhd_tree_inlining_start_inlining PARAMS ((tree));
void lhd_tree_inlining_end_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_NAME "GNU unknown"
#define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier) #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier)
...@@ -107,6 +108,8 @@ void lhd_tree_inlining_end_inlining PARAMS ((tree)); ...@@ -107,6 +108,8 @@ void lhd_tree_inlining_end_inlining PARAMS ((tree));
lhd_tree_inlining_start_inlining lhd_tree_inlining_start_inlining
#define LANG_HOOKS_TREE_INLINING_END_INLINING \ #define LANG_HOOKS_TREE_INLINING_END_INLINING \
lhd_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 { \ #define LANG_HOOKS_TREE_INLINING_INITIALIZER { \
LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \ LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \
...@@ -118,7 +121,8 @@ void lhd_tree_inlining_end_inlining PARAMS ((tree)); ...@@ -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_COPY_RES_DECL_FOR_INLINING, \
LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P, \ LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P, \
LANG_HOOKS_TREE_INLINING_START_INLINING, \ 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. */ /* Tree dump hooks. */
......
...@@ -277,6 +277,18 @@ lhd_tree_inlining_end_inlining (fn) ...@@ -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 /* 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 nodes. Returns non-zero if it does not want the usual dumping of the
second argument. */ second argument. */
......
...@@ -48,6 +48,9 @@ struct lang_hooks_for_tree_inlining ...@@ -48,6 +48,9 @@ struct lang_hooks_for_tree_inlining
int (*anon_aggr_type_p) PARAMS ((union tree_node *)); int (*anon_aggr_type_p) PARAMS ((union tree_node *));
int (*start_inlining) PARAMS ((union tree_node *)); int (*start_inlining) PARAMS ((union tree_node *));
void (*end_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. */ /* The following hooks are used by tree-dump.c. */
......
...@@ -64,6 +64,9 @@ static void objc_post_options PARAMS ((void)); ...@@ -64,6 +64,9 @@ static void objc_post_options PARAMS ((void));
#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P #undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \ #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \
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. */ /* Each front end provides its own hooks, for toplev.c. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
......
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> 2002-03-18 Jakub Jelinek <jakub@redhat.com>
* g++.dg/opt/conj1.C: New test. * g++.dg/opt/conj1.C: New test.
......
/* 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 ());
}
...@@ -483,7 +483,8 @@ initialize_inlined_parameters (id, args, fn) ...@@ -483,7 +483,8 @@ initialize_inlined_parameters (id, args, fn)
tree cleanup; tree cleanup;
/* Find the initializer. */ /* 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 /* If the parameter is never assigned to, we may not need to
create a new variable here at all. Instead, we may be able create a new variable here at all. Instead, we may be able
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment