Commit 700686fa by Ziemowit Laski Committed by Ziemowit Laski

c-typeck.c (build_c_cast): In ObjC...

[gcc/ChangeLog]
2004-08-25  Ziemowit Laski  <zlaski@apple.com>

       * c-typeck.c (build_c_cast): In ObjC, always preserve (and silently
       accept) a cast from one Objective-C pointer type to another.

[gcc/testsuite/ChangeLog]
2004-08-25  Ziemowit Laski  <zlaski@apple.com>

       * objc.dg/proto-lossage-4.m: New test.

From-SVN: r86574
parent 7fb654ef
2004-08-25 Ziemowit Laski <zlaski@apple.com>
* c-typeck.c (build_c_cast): In ObjC, always preserve (and silently
accept) a cast from one Objective-C pointer type to another.
2004-08-25 Paolo Carlini <pcarlini@suse.de> 2004-08-25 Paolo Carlini <pcarlini@suse.de>
* doc/install.texi: Document that libstdc++-v3 requires * doc/install.texi: Document that libstdc++-v3 requires
......
...@@ -2922,8 +2922,10 @@ build_c_cast (tree type, tree expr) ...@@ -2922,8 +2922,10 @@ build_c_cast (tree type, tree expr)
/* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
only in <protocol> qualifications. But when constructing cast expressions, only in <protocol> qualifications. But when constructing cast expressions,
the protocols do matter and must be kept around. */ the protocols do matter and must be kept around. */
if (!c_dialect_objc () || !objc_is_object_ptr (type)) if (objc_is_object_ptr (type) && objc_is_object_ptr (TREE_TYPE (expr)))
type = TYPE_MAIN_VARIANT (type); return build1 (NOP_EXPR, type, expr);
type = TYPE_MAIN_VARIANT (type);
if (TREE_CODE (type) == ARRAY_TYPE) if (TREE_CODE (type) == ARRAY_TYPE)
{ {
......
2004-08-25 Ziemowit Laski <zlaski@apple.com>
* objc.dg/proto-lossage-4.m: New test.
2004-08-25 Mark Mitchell <mark@codesourcery.com> 2004-08-25 Mark Mitchell <mark@codesourcery.com>
PR c++/17155 PR c++/17155
......
/* Test for situations in which protocol conformance information
may be lost while casting. */
/* 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 Proto
- (int)someValue;
@end
@interface Obj
- (int)anotherValue;
@end
int foo(void) {
int receiver = 2;
Obj *objrcvr;
Obj <Proto> *objrcvr2;
receiver += [receiver someValue]; /* { dg-warning "invalid receiver type .int( )?." } */
/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 22 } */
/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 22 } */
/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 22 } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 22 } */
receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .int( )?." } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 28 } */
receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 31 } */
receiver += [(Obj *)receiver anotherValue];
receiver += [(Obj <Proto> *)receiver someValue];
receiver += [(Obj <Proto> *)receiver anotherValue];
receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 37 } */
receiver += [objrcvr anotherValue];
receiver += [(Obj <Proto> *)objrcvr someValue];
receiver += [(Obj <Proto> *)objrcvr anotherValue];
receiver += [objrcvr2 someValue];
receiver += [objrcvr2 anotherValue];
receiver += [(Obj *)objrcvr2 someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 45 } */
receiver += [(Obj *)objrcvr2 anotherValue];
return receiver;
}
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