Home | History | Annotate | Download | only in dcl.init.ref
      1 // RUN: %clang_cc1 -ast-dump %s 2>&1 | FileCheck %s
      2 
      3 // CHECK: example0
      4 void example0() {
      5   double d = 2.0;
      6   // CHECK: VarDecl{{.*}}rd 'double &'
      7   // CHECK-NEXT: DeclRefExpr
      8   double &rd = d;
      9   // CHECK: VarDecl{{.*}}rcd 'const double &'
     10   // CHECK-NEXT: ImplicitCastExpr{{.*}}'const double' lvalue <NoOp>
     11   const double &rcd = d;
     12 }
     13 
     14 struct A { };
     15 struct B : A { } b;
     16 
     17 // CHECK: example1
     18 void example1() {
     19   // CHECK: VarDecl{{.*}}ra 'struct A &'
     20   // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue <DerivedToBase (A)>
     21   A &ra = b;
     22   // CHECK: VarDecl{{.*}}rca 'const struct A &'
     23   // CHECK: ImplicitCastExpr{{.*}}'const struct A' lvalue <NoOp>
     24   // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue <DerivedToBase (A)>
     25   const A& rca = b;
     26 }
     27 
     28 extern B f();
     29 
     30 struct X {
     31   operator B();
     32 } x;
     33 
     34 // CHECK: example2
     35 void example2() {
     36   // CHECK: VarDecl{{.*}}rca 'const struct A &'
     37   // CHECK: ImplicitCastExpr{{.*}}'const struct A' <NoOp>
     38   // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)>
     39   // CHECK: CallExpr{{.*}}B
     40   const A &rca = f();
     41   // CHECK: VarDecl{{.*}}r 'const struct A &'
     42   // CHECK: ImplicitCastExpr{{.*}}'const struct A' <NoOp>
     43   // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)>
     44   // CHECK: CXXMemberCallExpr{{.*}}'struct B'
     45   const A& r = x;
     46 }
     47 
     48 // CHECK: example3
     49 void example3() {
     50   // CHECK: VarDecl{{.*}}rcd2 'const double &'
     51   // CHECK: ImplicitCastExpr{{.*}} <IntegralToFloating>
     52   const double& rcd2 = 2;
     53 }
     54