forked from OSchip/llvm-project
objective-C: make -Widiomatic-parentheses work
when assignment expression in conditional invloves property reference. // rdar://11066598 llvm-svn: 162846
This commit is contained in:
parent
c0b4928df8
commit
f07bcc527a
|
@ -11191,7 +11191,9 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
|
|||
|
||||
IsOrAssign = Op->getOperator() == OO_PipeEqual;
|
||||
Loc = Op->getOperatorLoc();
|
||||
} else {
|
||||
} else if (PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(E))
|
||||
return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
|
||||
else {
|
||||
// Not an assignment.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,13 +4,18 @@
|
|||
// <rdar://problem/7382435>
|
||||
|
||||
@interface Object
|
||||
{
|
||||
unsigned uid;
|
||||
}
|
||||
- (id) init;
|
||||
- (id) initWithInt: (int) i;
|
||||
- (void) iterate: (id) coll;
|
||||
- (id) nextObject;
|
||||
@property unsigned uid;
|
||||
@end
|
||||
|
||||
@implementation Object
|
||||
@synthesize uid;
|
||||
- (id) init {
|
||||
if (self = [self init]) {
|
||||
}
|
||||
|
@ -20,6 +25,12 @@
|
|||
- (id) initWithInt: (int) i {
|
||||
if (self = [self initWithInt: i]) {
|
||||
}
|
||||
// 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}}
|
||||
// ...
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue