+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
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);
{
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));
}
{
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));
}
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
static void
objc_push_parm (tree parm)
{
- bool relayout_needed = false;
+ tree type;
if (TREE_TYPE (parm) == error_mark_node)
{
}
/* 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));
+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.
+
2010-09-28 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/foldconst-5.c: New testcase.
--- /dev/null
+/* Check if array and function parameters get decayed to pointers as
+ they should. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "../objc-obj-c++-shared/Object1.h"
+#include <string.h>
+#include <stdlib.h>
+
+static char global_buf[20];
+
+char *strcpy_like_callee(const char *s) {
+ strcpy(global_buf, s);
+ return global_buf;
+}
+
+typedef char io_string_t[512];
+typedef char *(func_type)(const char *);
+
+@interface DeviceObject: Object
+- (void) func:(func_type)func stucPathInIORegistry:(io_string_t)ioRegPath;
+@end
+@implementation DeviceObject
+- (void) func:(func_type)func stucPathInIORegistry:(io_string_t)ioRegPath
+{
+ func(ioRegPath);
+}
+@end
+
+int main (void) {
+ io_string_t my_string;
+ DeviceObject *obj = [DeviceObject new];
+
+ strcpy (my_string, "Hello!");
+ strcpy (global_buf, "Good-bye!");
+
+ [obj func:strcpy_like_callee stucPathInIORegistry:my_string];
+
+ if (strcmp (global_buf, "Hello!"))
+ abort ();
+
+ return 0;
+}
--- /dev/null
+/* Check if array and function parameters get decayed to pointers as
+ they should. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "../objc-obj-c++-shared/Object1.h"
+#include <string.h>
+#include <stdlib.h>
+
+static char global_buf[20];
+
+char *strcpy_like_callee(const char *s) {
+ strcpy(global_buf, s);
+ return global_buf;
+}
+
+typedef char io_string_t[512];
+typedef char *(func_type)(const char *);
+
+@interface DeviceObject: Object
+- (void) func:(func_type)func stucPathInIORegistry:(io_string_t)ioRegPath;
+@end
+@implementation DeviceObject
+- (void) func:(func_type)func stucPathInIORegistry:(io_string_t)ioRegPath
+{
+ func(ioRegPath);
+}
+@end
+
+int main (void) {
+ io_string_t my_string;
+ DeviceObject *obj = [DeviceObject new];
+
+ strcpy (my_string, "Hello!");
+ strcpy (global_buf, "Good-bye!");
+
+ [obj func:strcpy_like_callee stucPathInIORegistry:my_string];
+
+ if (strcmp (global_buf, "Hello!"))
+ abort ();
+
+ return 0;
+}