brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 393c084 Raw
50 lines · cpp
1// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -ast-dump %s \2// RUN: | FileCheck -strict-whitespace %s3 4struct S {5  struct {6    int i;7  };8};9 10int accessInRegularFunction() {11  return S().i;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 .i17  // CHECK-NEXT: |           `-MemberExpr {{.*}} 'S::(anonymous struct at {{.*}})18  // CHECK-NEXT: |             `-MaterializeTemporaryExpr {{.*}} 'S' xvalue19  // CHECK-NEXT: |               `-CXXTemporaryObjectExpr {{.*}} 'S' 'void () noexcept' zeroing20}21 22// AST should look the same in a function template with an unused template23// parameter.24template <class>25int accessInFunctionTemplate() {26  return S().i;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 .i32  // CHECK-NEXT: |           `-MemberExpr {{.*}} 'S::(anonymous struct at {{.*}})33  // CHECK-NEXT: |             `-MaterializeTemporaryExpr {{.*}} 'S' xvalue34  // CHECK-NEXT: |               `-CXXTemporaryObjectExpr {{.*}} 'S' 'void () noexcept' zeroing35}36 37// AST should look the same in an instantiation of the function template.38// This is a regression test: The AST used to contain the39// `MaterializeTemporaryExpr` in the wrong place, causing a `MemberExpr` to have40// a prvalue base (which is not allowed in C++).41template int accessInFunctionTemplate<int>();42  // CHECK: FunctionDecl {{.*}} accessInFunctionTemplate 'int ()' explicit_instantiation_definition43  // CHECK:          `-ReturnStmt {{.*}}44  // CHECK-NEXT:       `-ExprWithCleanups {{.*}} 'int'45  // CHECK-NEXT:         `-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>46  // CHECK-NEXT:           `-MemberExpr {{.*}} 'int' xvalue .i47  // CHECK-NEXT:             `-MemberExpr {{.*}} 'S::(anonymous struct at {{.*}})48  // CHECK-NEXT:               `-MaterializeTemporaryExpr {{.*}} 'S' xvalue49  // CHECK-NEXT:                 `-CXXTemporaryObjectExpr {{.*}} 'S' 'void () noexcept' zeroing50