objc-act.c (adjust_type_for_id_default): Do not allow an object as parameter.

* objc/objc-act.c (adjust_type_for_id_default): Do not allow an
        object as parameter. Prevent something like 'NSObject' to be
        used as the type for a method argument.

      testsuite:
      * objc.dg/param-1.m: New test.

From-SVN: r55197
This commit is contained in:
Devang Patel 2002-07-02 16:06:04 -07:00 committed by Devang Patel
parent 0879540b3d
commit c40da51899
4 changed files with 33 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2002-07-02 Devang Patel <dpatel@apple.com
* objc/objc-act.c (adjust_type_for_id_default): Do not allow an
object as parameter. Prevent something like 'NSObject' to be
used as the type for a method argument.
2002-07-03 Neil Booth <neil@daikokuya.co.uk>
* cpptrad.c: Update comment.

View File

@ -4465,6 +4465,10 @@ adjust_type_for_id_default (type)
chain;
chain = TREE_CHAIN (chain))
{
if (TREE_CODE (TREE_VALUE (chain)) == RECORD_TYPE
&& !(TREE_VALUE (type)
&& TREE_CODE (TREE_VALUE (type)) == INDIRECT_REF))
error ("can not use an object as parameter to a method\n");
if (!is_objc_type_qualifier (TREE_VALUE (chain)))
return type;
}

View File

@ -1,3 +1,6 @@
2002-07-02 Devang Patel <dpatel@apple.com>
* objc.dg/param-1.m: New test.
2002-07-03 Neil Booth <neil@daikokuya.co.uk>
* gcc.dg/cpp/trad/directive.c: Add test.

View File

@ -0,0 +1,20 @@
/* Test if compiler detects object as an parameter to a method
or not. It is not valid. */
/* { dg-do compile } */
@interface foo
@end
@implementation foo
@end
@interface bar
-(void) my_method:(foo) my_param; /* { dg-error "can not use an object as parameter to a method" } */
@end
@implementation bar
-(void) my_method:(foo) my_param /* { dg-error "can not use an object as parameter to a method" } */
{
}
@end