brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · bed3f0a Raw
52 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wparentheses -Wno-objc-root-class %s2 3// Don't warn about some common ObjC idioms unless we have -Widiomatic-parentheses on.4 5@interface Object 6{7  unsigned uid;8}9- (id) init;10- (id) initWithInt: (int) i;11- (id) myInit __attribute__((objc_method_family(init)));12- (void) iterate: (id) coll;13- (id) nextObject;14@property unsigned uid;15@end16 17@implementation Object18@synthesize uid;19- (id) init {20  if (self = [self init]) {21  }22  return self;23}24 25- (id) initWithInt: (int) i {26  if (self = [self initWithInt: i]) {27  }28  if (self.uid = 100) { // expected-warning {{using the result of an assignment as a condition without parentheses}} \29                        // expected-note {{place parentheses around the assignment to silence this warning}} \30                        // expected-note {{use '==' to turn this assignment into an equality comparison}}31        // ...32  }33  return self;34}35 36- (id) myInit {37  if (self = [self myInit]) {38  }39  return self;40}41 42- (void) iterate: (id) coll {43  id cur;44  while (cur = [coll nextObject]) {45  }46}47 48- (id) nextObject {49  return self;50}51@end52