c-lang.c (objc_is_id): New stub.
[gcc/ChangeLog] 2002-09-06 Ziemowit Laski <zlaski@apple.com> * c-lang.c (objc_is_id): New stub. * c-tree.h (objc_is_id): New forward declaration. * c-typeck.c (build_c_cast): Do not strip protocol qualifiers from 'id' type. * objc/objc-act.c (objc_comptypes): Correct handling of protocol qualifiers. (objc_is_id): New. [gcc/testsuite/ChangeLog] 2002-09-05 Ziemowit Laski <zlaski@apple.com> * objc.dg/proto-lossage-1.m: New test. From-SVN: r56905
This commit is contained in:
parent
5fc0e5dfb4
commit
370ce32a02
@ -1,3 +1,13 @@
|
||||
2002-09-06 Ziemowit Laski <zlaski@apple.com>
|
||||
|
||||
* c-lang.c (objc_is_id): New stub.
|
||||
* c-tree.h (objc_is_id): New forward declaration.
|
||||
* c-typeck.c (build_c_cast): Do not strip protocol
|
||||
qualifiers from 'id' type.
|
||||
* objc/objc-act.c (objc_comptypes): Correct handling
|
||||
of protocol qualifiers.
|
||||
(objc_is_id): New.
|
||||
|
||||
Fri Sep 6 13:10:08 2002 Jeffrey A Law (law@redhat.com)
|
||||
|
||||
* pentium.md (pentium-firstvboth): Fix typo.
|
||||
|
@ -174,6 +174,13 @@ is_class_name (arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
tree
|
||||
objc_is_id (arg)
|
||||
tree arg ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
objc_check_decl (decl)
|
||||
tree decl ATTRIBUTE_UNUSED;
|
||||
|
@ -165,6 +165,7 @@ struct lang_type GTY(())
|
||||
/* in c-lang.c and objc-act.c */
|
||||
extern tree lookup_interface PARAMS ((tree));
|
||||
extern tree is_class_name PARAMS ((tree));
|
||||
extern tree objc_is_id PARAMS ((tree));
|
||||
extern void objc_check_decl PARAMS ((tree));
|
||||
extern void finish_file PARAMS ((void));
|
||||
extern int objc_comptypes PARAMS ((tree, tree, int));
|
||||
|
@ -3577,7 +3577,12 @@ build_c_cast (type, expr)
|
||||
|
||||
if (type == error_mark_node || expr == error_mark_node)
|
||||
return error_mark_node;
|
||||
type = TYPE_MAIN_VARIANT (type);
|
||||
|
||||
/* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
|
||||
only in <protocol> qualifications. But when constructing cast expressions,
|
||||
the protocols do matter and must be kept around. */
|
||||
if (!flag_objc || !objc_is_id (type))
|
||||
type = TYPE_MAIN_VARIANT (type);
|
||||
|
||||
#if 0
|
||||
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
|
||||
|
@ -648,13 +648,16 @@ objc_comptypes (lhs, rhs, reflexive)
|
||||
tree cat;
|
||||
|
||||
rproto_list = CLASS_PROTOCOL_LIST (rinter);
|
||||
/* If the underlying ObjC class does not have
|
||||
protocols attached to it, perhaps there are
|
||||
"one-off" protocols attached to the rhs?
|
||||
E.g., 'id<MyProt> foo;'. */
|
||||
if (!rproto_list)
|
||||
rproto_list = TYPE_PROTOCOL_LIST (TREE_TYPE (rhs));
|
||||
rproto = lookup_protocol_in_reflist (rproto_list, p);
|
||||
/* If the underlying ObjC class does not have
|
||||
the protocol we're looking for, check for "one-off"
|
||||
protocols (e.g., `NSObject<MyProt> foo;') attached
|
||||
to the rhs. */
|
||||
if (!rproto)
|
||||
{
|
||||
rproto_list = TYPE_PROTOCOL_LIST (TREE_TYPE (rhs));
|
||||
rproto = lookup_protocol_in_reflist (rproto_list, p);
|
||||
}
|
||||
|
||||
/* Check for protocols adopted by categories. */
|
||||
cat = CLASS_CATEGORY_LIST (rinter);
|
||||
@ -2261,6 +2264,17 @@ is_class_name (ident)
|
||||
return 0;
|
||||
}
|
||||
|
||||
tree
|
||||
objc_is_id (ident)
|
||||
tree ident;
|
||||
{
|
||||
/* NB: This function may be called before the ObjC front-end
|
||||
has been initialized, in which case ID_TYPE will be NULL. */
|
||||
return (id_type && ident && TYPE_P (ident) && IS_ID (ident))
|
||||
? id_type
|
||||
: NULL_TREE;
|
||||
}
|
||||
|
||||
tree
|
||||
lookup_interface (ident)
|
||||
tree ident;
|
||||
|
@ -1,3 +1,7 @@
|
||||
2002-09-05 Ziemowit Laski <zlaski@apple.com>
|
||||
|
||||
* objc.dg/proto-lossage-1.m: New test.
|
||||
|
||||
2002-09-06 Neil Booth <neil@daikokuya.co.uk>
|
||||
|
||||
* gcc.dg/cpp/_Pragma4.c: Fix typo.
|
||||
|
43
gcc/testsuite/objc.dg/proto-lossage-1.m
Normal file
43
gcc/testsuite/objc.dg/proto-lossage-1.m
Normal file
@ -0,0 +1,43 @@
|
||||
/* Test for situations in which protocol conformance information
|
||||
may be lost, leading to superfluous warnings. */
|
||||
/* Author: Ziemowit Laski <zlaski@apple.com>. */
|
||||
/* { dg-do compile } */
|
||||
|
||||
/* One-line substitute for objc/objc.h */
|
||||
typedef struct objc_object { struct objc_class *class_pointer; } *id;
|
||||
|
||||
@protocol NSObject
|
||||
- (int)someValue;
|
||||
@end
|
||||
|
||||
@interface NSObject <NSObject>
|
||||
@end
|
||||
|
||||
@protocol PlateMethods
|
||||
- (void)someMethod;
|
||||
@end
|
||||
|
||||
@interface Foo {
|
||||
NSObject <PlateMethods> *plate;
|
||||
id <PlateMethods> plate1;
|
||||
NSObject *plate2;
|
||||
}
|
||||
- (id <PlateMethods>) getPlate;
|
||||
- (id <NSObject>) getPlate1;
|
||||
- (int) getValue;
|
||||
@end
|
||||
|
||||
@implementation Foo
|
||||
- (id <PlateMethods>) getPlate {
|
||||
return plate; /* { dg-bogus "does not implement" } */
|
||||
}
|
||||
- (id <NSObject>) getPlate1 {
|
||||
return (id <NSObject>)plate1; /* { dg-bogus "does not conform" } */
|
||||
}
|
||||
- (int) getValue {
|
||||
int i = [plate1 someValue]; /* { dg-warning "not implemented by protocol" } */
|
||||
int j = [(id <NSObject>)plate1 someValue]; /* { dg-bogus "not implemented by protocol" } */
|
||||
int k = [(id)plate1 someValue]; /* { dg-bogus "not implemented by protocol" } */
|
||||
return i + j + k;
|
||||
}
|
||||
@end
|
Loading…
Reference in New Issue
Block a user