aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/objc')
-rw-r--r--gcc/objc/ChangeLog13
-rw-r--r--gcc/objc/objc-act.c43
2 files changed, 37 insertions, 19 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 5263b40..65d61b1 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,16 @@
+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.
+
2010-09-28 Nicola Pero <nicola@nicola.brainstorm.co.uk>
* objc-act.c (encode_type): Fixed encoding enums with the next
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));