Commit 26877873 by Nicola Pero Committed by Nicola Pero

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
parent a00ac533
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
......
......@@ -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));
......
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.
......
/* 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;
}
/* 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;
}
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