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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165111
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
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.
--- /dev/null
+
+/* { 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];
+}
--- /dev/null
+
+/* { 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];
+}