Home | History | Annotate | Download | only in SemaObjCXX
      1 // RUN: %clang_cc1 -verify -o - %s
      2 
      3 __attribute__((objc_root_class))
      4 @interface Root @end
      5 
      6 // Test reference binding.
      7 
      8 typedef struct {
      9   int f0;
     10   int f1;
     11 } T;
     12 
     13 @interface A : Root
     14 @property (assign) T p0;
     15 @property (assign) T& p1; 
     16 @end
     17 
     18 int f0(const T& t) {
     19   return t.f0;
     20 }
     21 
     22 int f1(A *a) {
     23   return f0(a.p0);
     24 }
     25 
     26 int f2(A *a) {
     27   return f0(a.p1);	
     28 }
     29 
     30 // PR7740
     31 @class NSString;
     32 
     33 void f3(id);
     34 void f4(NSString &tmpstr) {
     35   f3(&tmpstr);
     36 }
     37 
     38 // PR7741
     39 @protocol P1 @end
     40 @protocol P2 @end
     41 @protocol P3 @end
     42 @interface foo<P1> {} @end
     43 @interface bar : foo <P1, P2, P3> {} @end
     44 typedef bar baz;
     45 
     46 struct ToBar {
     47   operator bar&() const;
     48 };
     49 
     50 void f5(foo&);
     51 void f5b(foo<P1>&);
     52 void f5c(foo<P2>&);
     53 void f5d(foo<P3>&);
     54 void f6(baz* x) { 
     55   f5(*x); 
     56   f5b(*x); 
     57   f5c(*x); 
     58   f5d(*x);
     59   (void)((foo&)*x);
     60   f5(ToBar());
     61   f5b(ToBar());
     62   f5c(ToBar());
     63   f5d(ToBar());
     64   (void)((foo&)ToBar());
     65 }
     66 
     67 // rdar://13794269
     68 @interface B : Root @end
     69 @implementation B {
     70   unsigned bf : 4; // expected-note {{declared here}}
     71 }
     72 
     73 - (void) foo {
     74   unsigned &i = bf; // expected-error {{non-const reference cannot bind to bit-field 'bf'}}
     75 }
     76 @end
     77