Commit fd651069 by Iain Sandoe

do not emit bogus set-not-used warnings for objc* entities used as message receivers.

gcc/objc:
	* objc-act.c (objc_build_message_expr):  Call mark_exp_read () to signal that
	the receiver has been used.
gcc/testsuite:
	* objc.dg/set-not-used-1.m: New
	* obj-c++.dg/set-not-used-1.mm: New.

From-SVN: r165111
parent 518ade91
2010-10-07 Iain Sandoe <iains@gcc.gnu.org>
* objc-act.c (objc_build_message_expr): Call mark_exp_read () to signal that
the receiver has been used.
2010-10-06 Nicola Pero <nicola.pero@meta-innovation.com>
* README: Obsolete file removed.
......
......@@ -6455,6 +6455,9 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
tree selector, retval, class_tree;
int self, super, have_cast;
/* We have used the receiver, so mark it as read. */
mark_exp_read (receiver);
/* Extract the receiver of the message, as well as its type
(where the latter may take the form of a cast or be inferred
from the implementation context). */
......
2010-10-07 Iain Sandoe <iains@gcc.gnu.org>
* objc.dg/set-not-used-1.m: New
* obj-c++.dg/set-not-used-1.mm: New.
2010-10-07 Iain Sandoe <iains@gcc.gnu.org>
* objc.dg/attributes/method-attribute-3.m: New.
* obj-c++.dg/attributes/method-attribute-3.mm: New.
......
/* { dg-do compile } */
/* { dg-options "-Wunused-but-set-variable" } */
#import "../objc-obj-c++-shared/Object1.h"
#include <objc/objc-api.h>
@interface obj : Object
{
int value;
}
- (int) value;
- (void) setValue: (int)number;
@end
@implementation obj : Object
- (int) value { return value; }
- (void) setValue: (int)number { value = number; }
@end
int main (void)
{
obj *a; /* { dg-bogus "set but not used" } */
obj *b; /* { dg-bogus "set but not used" } */
obj *c; /* { dg-warning "set but not used" } */
a = [obj new];
b = [obj new];
c = [obj new];
[b setValue: [a value]];
return [a value];
}
/* { dg-do compile } */
/* { dg-options "-Wunused-but-set-variable" } */
#import "../objc-obj-c++-shared/Object1.h"
#include <objc/objc-api.h>
@interface obj : Object
{
int value;
}
- (int) value;
- (void) setValue: (int)number;
@end
@implementation obj : Object
- (int) value { return value; }
- (void) setValue: (int)number { value = number; }
@end
int main (void)
{
obj *a; /* { dg-bogus "set but not used" } */
obj *b; /* { dg-bogus "set but not used" } */
obj *c; /* { dg-warning "set but not used" } */
a = [obj new];
b = [obj new];
c = [obj new];
[b setValue: [a value]];
return [a value];
}
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