From 88d752103b5f46ee47d9af48c2c6b8ff013aaf5e Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 21 Dec 2007 00:35:35 +0000 Subject: [PATCH] Test case for my last patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45277 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Sema/objc-comptypes-3.m | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 test/Sema/objc-comptypes-3.m diff --git a/test/Sema/objc-comptypes-3.m b/test/Sema/objc-comptypes-3.m new file mode 100644 index 0000000000..c7c4cab711 --- /dev/null +++ b/test/Sema/objc-comptypes-3.m @@ -0,0 +1,62 @@ +// RUN: clang -fsyntax-only -verify %s +extern void foo(); +#include + +@protocol MyProtocolA +- (void) methodA; +@end + +@protocol MyProtocolB +- (void) methodB; +@end + +@protocol MyProtocolAB +@end + +@protocol MyProtocolAC +- (void) methodC; +@end + +int main() +{ + id obj_a = nil; + id obj_b = nil; + id obj_ab = nil; + id obj_ac = nil; + + obj_a = obj_b; // expected-error {{incompatible types assigning 'id' to 'id'}} + obj_a = obj_ab; /* Ok */ + obj_a = obj_ac; /* Ok */ + + obj_b = obj_a; // expected-error {{incompatible types assigning 'id' to 'id'}} + obj_b = obj_ab; /* Ok */ + obj_b = obj_ac; // expected-error {{incompatible types assigning 'id' to 'id'}} + + obj_ab = obj_a; // expected-error {{incompatible types assigning 'id' to 'id'}} + obj_ab = obj_b; // expected-error {{incompatible types assigning 'id' to 'id'}} + obj_ab = obj_ac; // expected-error {{incompatible types assigning 'id' to 'id'}} + + obj_ac = obj_a; // expected-error {{incompatible types assigning 'id' to 'id'}} + obj_ac = obj_b; // expected-error {{incompatible types assigning 'id' to 'id'}} + obj_ac = obj_ab; // expected-error {{incompatible types assigning 'id' to 'id'}} + + if (obj_a == obj_b) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + if (obj_b == obj_a) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + + if (obj_a == obj_ab) foo (); /* Ok */ + if (obj_ab == obj_a) foo (); /* Ok */ + + if (obj_a == obj_ac) foo (); /* Ok */ + if (obj_ac == obj_a) foo (); /* Ok */ + + if (obj_b == obj_ab) foo (); /* Ok */ + if (obj_ab == obj_b) foo (); /* Ok */ + + if (obj_b == obj_ac) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + if (obj_ac == obj_b) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + + if (obj_ab == obj_ac) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + if (obj_ac == obj_ab) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + + return 0; +}