1 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -ast-dump %s \
2 // RUN: | FileCheck -strict-whitespace %s
10 int accessInRegularFunction() {
12 // CHECK: FunctionDecl {{.*}} accessInRegularFunction 'int ()'
13 // CHECK: | `-ReturnStmt {{.*}}
14 // CHECK-NEXT: | `-ExprWithCleanups {{.*}} 'int'
15 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
16 // CHECK-NEXT: | `-MemberExpr {{.*}} 'int' xvalue .i
17 // CHECK-NEXT: | `-MemberExpr {{.*}} 'S::(anonymous struct at {{.*}})
18 // CHECK-NEXT: | `-MaterializeTemporaryExpr {{.*}} 'S' xvalue
19 // CHECK-NEXT: | `-CXXTemporaryObjectExpr {{.*}} 'S' 'void () noexcept' zeroing
22 // AST should look the same in a function template with an unused template
25 int accessInFunctionTemplate() {
27 // CHECK: FunctionDecl {{.*}} accessInFunctionTemplate 'int ()'
28 // CHECK: | `-ReturnStmt {{.*}}
29 // CHECK-NEXT: | `-ExprWithCleanups {{.*}} 'int'
30 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
31 // CHECK-NEXT: | `-MemberExpr {{.*}} 'int' xvalue .i
32 // CHECK-NEXT: | `-MemberExpr {{.*}} 'S::(anonymous struct at {{.*}})
33 // CHECK-NEXT: | `-MaterializeTemporaryExpr {{.*}} 'S' xvalue
34 // CHECK-NEXT: | `-CXXTemporaryObjectExpr {{.*}} 'S' 'void () noexcept' zeroing
37 // AST should look the same in an instantiation of the function template.
38 // This is a regression test: The AST used to contain the
39 // `MaterializeTemporaryExpr` in the wrong place, causing a `MemberExpr` to have
40 // a prvalue base (which is not allowed in C++).
41 template int accessInFunctionTemplate
<int>();
42 // CHECK: FunctionDecl {{.*}} accessInFunctionTemplate 'int ()' explicit_instantiation_definition
43 // CHECK: `-ReturnStmt {{.*}}
44 // CHECK-NEXT: `-ExprWithCleanups {{.*}} 'int'
45 // CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
46 // CHECK-NEXT: `-MemberExpr {{.*}} 'int' xvalue .i
47 // CHECK-NEXT: `-MemberExpr {{.*}} 'S::(anonymous struct at {{.*}})
48 // CHECK-NEXT: `-MaterializeTemporaryExpr {{.*}} 'S' xvalue
49 // CHECK-NEXT: `-CXXTemporaryObjectExpr {{.*}} 'S' 'void () noexcept' zeroing