summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-08-08 18:03:17 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-08-08 18:03:17 +0000
commit5ac085ab3ac779b5819b4e02cdd26fa1b5ac79f6 (patch)
treec3c81c1638ca25421f390b8ad277e4b71a3060e2 /clang/test
parent62422209667ec09be01ae31734bfc3c395c890e1 (diff)
downloadbcm5719-llvm-5ac085ab3ac779b5819b4e02cdd26fa1b5ac79f6.tar.gz
bcm5719-llvm-5ac085ab3ac779b5819b4e02cdd26fa1b5ac79f6.zip
objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance) "conformsTo" two protocols which conflict (have methods which conflict). This patch fixes the previous patch where warnings were coming out in non-deterministic order. This is 2nd part of // rdar://6191214. llvm-svn: 137055
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaObjC/class-protocol-method-match.m6
-rw-r--r--clang/test/SemaObjC/qualified-protocol-method-conflicts.m39
2 files changed, 42 insertions, 3 deletions
diff --git a/clang/test/SemaObjC/class-protocol-method-match.m b/clang/test/SemaObjC/class-protocol-method-match.m
index bffdb79e074..4022ce3aee5 100644
--- a/clang/test/SemaObjC/class-protocol-method-match.m
+++ b/clang/test/SemaObjC/class-protocol-method-match.m
@@ -4,7 +4,7 @@
@protocol Bar
@required
- (unsigned char) baz; // expected-note {{previous definition is here}}
-- (char) ok;
+- (char) ok; // expected-note {{previous definition is here}}
- (void) also_ok;
@end
@@ -17,11 +17,11 @@
@protocol Baz <Bar, Bar1>
- (void) bar : (unsigned char)arg; // expected-note {{previous definition is here}}
-- (void) ok;
+- (void) ok; // expected-warning {{conflicting return type in declaration of 'ok': 'char' vs 'void'}}
- (char) bak; // expected-note {{previous definition is here}}
@end
-@interface Foo <Baz>
+@interface Foo <Baz> // expected-note {{class is declared here}}
- (void) baz; // expected-warning {{conflicting return type in declaration of 'baz': 'unsigned char' vs 'void'}}
- (void) bar : (unsigned char*)arg; // expected-warning {{conflicting parameter types in declaration of 'bar:': 'unsigned char' vs 'unsigned char *'}}
- (void) ok;
diff --git a/clang/test/SemaObjC/qualified-protocol-method-conflicts.m b/clang/test/SemaObjC/qualified-protocol-method-conflicts.m
new file mode 100644
index 00000000000..da83c8338c1
--- /dev/null
+++ b/clang/test/SemaObjC/qualified-protocol-method-conflicts.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://6191214
+
+@protocol Xint
+-(void) setX: (int) arg0; // expected-note 3 {{previous definition is here}}
++(int) C; // expected-note 3 {{previous definition is here}}
+@end
+
+@protocol Xfloat
+-(void) setX: (float) arg0; // expected-warning 3 {{conflicting parameter types in declaration of 'setX:': 'int' vs 'float'}}
++(float) C; // expected-warning 3 {{conflicting return type in declaration of 'C': 'int' vs 'float'}}
+@end
+
+@interface A <Xint, Xfloat> // expected-note {{class is declared here}}
+@end
+
+@implementation A
+-(void) setX: (int) arg0 { }
++(int) C {return 0; }
+@end
+
+@interface B <Xfloat, Xint> // expected-note {{class is declared here}}
+@end
+
+@implementation B
+-(void) setX: (float) arg0 { }
++ (float) C {return 0.0; }
+@end
+
+@protocol Xint_float<Xint, Xfloat>
+@end
+
+@interface C<Xint_float> // expected-note {{class is declared here}}
+@end
+
+@implementation C
+-(void) setX: (int) arg0 { }
++ (int) C {return 0;}
+@end
OpenPOWER on IntegriCloud