xref: /aosp_15_r20/external/clang/test/SemaObjC/property-ivar-mismatch.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*67e74705SXin Li// Test that arithmatic types on property and its ivar have exact match.
3*67e74705SXin Li
4*67e74705SXin Li@interface Test4
5*67e74705SXin Li{
6*67e74705SXin Li   char ivar; // expected-note{{instance variable is declared here}}
7*67e74705SXin Li}
8*67e74705SXin Li@property int prop;
9*67e74705SXin Li@end
10*67e74705SXin Li
11*67e74705SXin Li@implementation Test4
12*67e74705SXin Li@synthesize prop = ivar;  // expected-error {{type of property 'prop' ('int') does not match type of instance variable 'ivar' ('char')}}
13*67e74705SXin Li@end
14*67e74705SXin Li
15*67e74705SXin Li
16*67e74705SXin Li@interface Test5
17*67e74705SXin Li{
18*67e74705SXin Li  void * _P; // expected-note {{instance variable is declared here}}
19*67e74705SXin Li}
20*67e74705SXin Li@property int P;
21*67e74705SXin Li@end
22*67e74705SXin Li
23*67e74705SXin Li@implementation Test5
24*67e74705SXin Li@synthesize P=_P; // expected-error {{ype of property 'P' ('int') does not match type of instance variable '_P' ('void *')}}
25*67e74705SXin Li@end
26*67e74705SXin Li
27