diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-09-28 17:58:55 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-09-28 17:58:55 +0000 |
commit | 2687787342ebaddbc21e2074d7adb46ff630bc33 (patch) | |
tree | 222e7d1bcfa9a85e0e42abfaa76ed4e639156e1f /gcc/objc/objc-act.c | |
parent | a00ac5336e5e3637cf7efabfa950cf9d4a074017 (diff) | |
download | gcc-2687787342ebaddbc21e2074d7adb46ff630bc33.zip gcc-2687787342ebaddbc21e2074d7adb46ff630bc33.tar.gz gcc-2687787342ebaddbc21e2074d7adb46ff630bc33.tar.bz2 |
In gcc/objc/: 2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/:
2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
2005-08-23 Stuart Hastings <stuart@apple.com>
Ziemowit Laski <zlaski@apple.com>
Radar 4209854
* objc-act.c (objc_decay_parm_type): New function.
(get_arg_type_list): Decay types for all named arguments.
(objc_push_parm): Rebuild the PARM_DECL if its type has
been decayed.
In gcc/testsuite/:
2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers (test method-20.m
from the branch renamed to method-20b.m to avoid clashes).
2005-08-23 Stuart Hastings <stuart@apple.com>
Ziemowit Laski <zlaski@apple.com>
Radar 4209854
* obj-c++.dg/method-23.mm: New.
* objc.dg/method-20.m: New.
From-SVN: r164694
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r-- | gcc/objc/objc-act.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 8013252..8e6c683 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -213,6 +213,7 @@ static void really_start_method (tree, tree); static void really_start_method (tree, struct c_arg_info *); #endif static int comp_proto_with_proto (tree, tree, int); +static tree objc_decay_parm_type (tree); static void objc_push_parm (tree); #ifdef OBJCPLUS static tree objc_get_parm_info (int); @@ -6108,11 +6109,8 @@ get_arg_type_list (tree meth, int context, int superflag) { tree arg_type = TREE_VALUE (TREE_TYPE (akey)); - /* Decay arrays and functions into pointers. */ - if (TREE_CODE (arg_type) == ARRAY_TYPE) - arg_type = build_pointer_type (TREE_TYPE (arg_type)); - else if (TREE_CODE (arg_type) == FUNCTION_TYPE) - arg_type = build_pointer_type (arg_type); + /* Decay argument types for the underlying C function as appropriate. */ + arg_type = objc_decay_parm_type (arg_type); chainon (arglist, build_tree_list (NULL_TREE, arg_type)); } @@ -6124,6 +6122,8 @@ get_arg_type_list (tree meth, int context, int superflag) { tree arg_type = TREE_TYPE (TREE_VALUE (akey)); + arg_type = objc_decay_parm_type (arg_type); + chainon (arglist, build_tree_list (NULL_TREE, arg_type)); } @@ -8599,6 +8599,19 @@ encode_field_decl (tree field_decl, int curtype, int format) encode_type (TREE_TYPE (field_decl), curtype, format); } +/* Decay array and function parameters into pointers. */ + +static tree +objc_decay_parm_type (tree type) +{ + if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == FUNCTION_TYPE) + type = build_pointer_type (TREE_CODE (type) == ARRAY_TYPE + ? TREE_TYPE (type) + : type); + + return type; +} + static GTY(()) tree objc_parmlist = NULL_TREE; /* Append PARM to a list of formal parameters of a method, making a necessary @@ -8607,7 +8620,7 @@ static GTY(()) tree objc_parmlist = NULL_TREE; static void objc_push_parm (tree parm) { - bool relayout_needed = false; + tree type; if (TREE_TYPE (parm) == error_mark_node) { @@ -8616,20 +8629,12 @@ objc_push_parm (tree parm) } /* Decay arrays and functions into pointers. */ - if (TREE_CODE (TREE_TYPE (parm)) == ARRAY_TYPE) - { - TREE_TYPE (parm) = build_pointer_type (TREE_TYPE (TREE_TYPE (parm))); - relayout_needed = true; - } - else if (TREE_CODE (TREE_TYPE (parm)) == FUNCTION_TYPE) - { - TREE_TYPE (parm) = build_pointer_type (TREE_TYPE (parm)); - relayout_needed = true; - } + type = objc_decay_parm_type (TREE_TYPE (parm)); - if (relayout_needed) - relayout_decl (parm); - + /* If the parameter type has been decayed, a new PARM_DECL needs to be + built as well. */ + if (type != TREE_TYPE (parm)) + parm = build_decl (input_location, PARM_DECL, DECL_NAME (parm), type); DECL_ARG_TYPE (parm) = lang_hooks.types.type_promotes_to (TREE_TYPE (parm)); |