xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/conditional-expr-2.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@interface A
4*f4a2713aSLionel Sambuc@end
5*f4a2713aSLionel Sambuc@interface B
6*f4a2713aSLionel Sambuc@end
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambucvoid f0(int cond, A *a, B *b) {
9*f4a2713aSLionel Sambuc  // Ensure that we can still send a message to result of incompatible
10*f4a2713aSLionel Sambuc  // conditional expression.
11*f4a2713aSLionel Sambuc  [ (cond ? a : b) test ]; // expected-warning{{incompatible operand types ('A *' and 'B *')}} expected-warning {{method '-test' not found}}
12*f4a2713aSLionel Sambuc}
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc@interface NSKey @end
15*f4a2713aSLionel Sambuc@interface KeySub : NSKey @end
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc@interface UpdatesList @end
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambucvoid foo (int i, NSKey *NSKeyValueCoding_NullValue, UpdatesList *nukedUpdatesList)
20*f4a2713aSLionel Sambuc{
21*f4a2713aSLionel Sambuc  id obj;
22*f4a2713aSLionel Sambuc  NSKey *key;
23*f4a2713aSLionel Sambuc  KeySub *keysub;
24*f4a2713aSLionel Sambuc
25*f4a2713aSLionel Sambuc  obj = i ? NSKeyValueCoding_NullValue : nukedUpdatesList; // expected-warning{{incompatible operand types ('NSKey *' and 'UpdatesList *')}}
26*f4a2713aSLionel Sambuc  key = i ? NSKeyValueCoding_NullValue : nukedUpdatesList; // expected-warning{{incompatible operand types ('NSKey *' and 'UpdatesList *')}}
27*f4a2713aSLionel Sambuc  key = i ? NSKeyValueCoding_NullValue : keysub;
28*f4a2713aSLionel Sambuc  keysub = i ? NSKeyValueCoding_NullValue : keysub; // expected-warning{{incompatible pointer types assigning to 'KeySub *' from 'NSKey *'}}
29*f4a2713aSLionel Sambuc}
30