mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-11 14:17:23 +08:00
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:
parent
0879540b3d
commit
c40da51899
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
20
gcc/testsuite/objc.dg/param-1.m
Normal file
20
gcc/testsuite/objc.dg/param-1.m
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user