diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/c-lang.c | 3 | ||||
-rw-r--r-- | gcc/c-tree.h | 1 | ||||
-rw-r--r-- | gcc/c-typeck.c | 24 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 6 | ||||
-rw-r--r-- | gcc/langhooks.c | 12 | ||||
-rw-r--r-- | gcc/langhooks.h | 3 | ||||
-rw-r--r-- | gcc/objc/objc-lang.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/20020318-1.c | 16 | ||||
-rw-r--r-- | gcc/tree-inline.c | 3 |
11 files changed, 89 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ecaedd0dec5..795c75f1932 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-lang.c b/gcc/c-lang.c index bb26001f185..325ebd5d15d 100644 --- a/gcc/c-lang.c +++ b/gcc/c-lang.c @@ -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!! ### */ diff --git a/gcc/c-tree.h b/gcc/c-tree.h index d39e3ff6e83..f01b5238d0e 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -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. */ diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index b28466122fa..1772557449c 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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'". diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index ffc86d3958e..abd28471f8f 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -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. */ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index a976d748029..6be5304a328 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -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. */ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index c7e43ce63f7..902bb55bc8c 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -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. */ diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c index 8f1a68bbfcf..d779e69d247 100644 --- a/gcc/objc/objc-lang.c +++ b/gcc/objc/objc-lang.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c25a2f43d50..f5cd64c333b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 00000000000..097a35d7956 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20020318-1.c @@ -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 ()); +} diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ce548849d2d..831f6019c7b 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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 |