2012-04-07 02:12:22 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wparentheses -Wno-objc-root-class %s
|
2009-11-12 08:06:05 +08:00
|
|
|
|
2011-04-30 04:30:39 +08:00
|
|
|
// Don't warn about some common ObjC idioms unless we have -Widiomatic-parentheses on.
|
2009-11-12 08:06:05 +08:00
|
|
|
// <rdar://problem/7382435>
|
|
|
|
|
|
|
|
@interface Object
|
2012-08-30 01:17:11 +08:00
|
|
|
{
|
|
|
|
unsigned uid;
|
|
|
|
}
|
2009-11-12 08:06:05 +08:00
|
|
|
- (id) init;
|
|
|
|
- (id) initWithInt: (int) i;
|
2013-07-18 02:17:14 +08:00
|
|
|
- (id) myInit __attribute__((objc_method_family(init)));
|
2009-11-12 08:06:05 +08:00
|
|
|
- (void) iterate: (id) coll;
|
|
|
|
- (id) nextObject;
|
2012-08-30 01:17:11 +08:00
|
|
|
@property unsigned uid;
|
2009-11-12 08:06:05 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Object
|
2012-08-30 01:17:11 +08:00
|
|
|
@synthesize uid;
|
2009-11-12 08:06:05 +08:00
|
|
|
- (id) init {
|
|
|
|
if (self = [self init]) {
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithInt: (int) i {
|
|
|
|
if (self = [self initWithInt: i]) {
|
|
|
|
}
|
2012-08-30 01:17:11 +08:00
|
|
|
// rdar://11066598
|
|
|
|
if (self.uid = 100) { // expected-warning {{using the result of an assignment as a condition without parentheses}} \
|
|
|
|
// expected-note {{place parentheses around the assignment to silence this warning}} \
|
|
|
|
// expected-note {{use '==' to turn this assignment into an equality comparison}}
|
|
|
|
// ...
|
|
|
|
}
|
2009-11-12 08:06:05 +08:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2013-07-18 02:17:14 +08:00
|
|
|
- (id) myInit {
|
|
|
|
if (self = [self myInit]) {
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2009-11-12 08:06:05 +08:00
|
|
|
- (void) iterate: (id) coll {
|
|
|
|
id cur;
|
|
|
|
while (cur = [coll nextObject]) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) nextObject {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|