83 lines · cpp
1// RUN: %clang_cc1 -std=c++98 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s2// RUN: %clang_cc1 -std=c++11 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX113// RUN: %clang_cc1 -std=c++14 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX144// RUN: %clang_cc1 -std=c++17 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX145// RUN: %clang_cc1 -std=c++20 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX146// RUN: %clang_cc1 -std=c++23 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX147// RUN: %clang_cc1 -std=c++2c %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX148// RUN: %clang_cc1 -std=c++1z %s -fexceptions -fcxx-exceptions -pedantic-errors -triple i386-windows-pc -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX149 10namespace cwg1772 { // cwg1772: 1411 // __func__ in a lambda should name operator(), not the containing function.12 // CHECK: NamespaceDecl{{.+}}cwg177213#if __cplusplus >= 201103L14 auto x = []() { __func__; };15 // CXX11: LambdaExpr16 // CXX11: CXXRecordDecl17 // CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'18 // CXX11-NEXT: CompoundStmt19 // CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__20 // CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()"21 22 void func() {23 // CXX11: FunctionDecl{{.+}} func24 (void)[]() { __func__; };25 // CXX11-NEXT: CompoundStmt26 // CXX11: LambdaExpr27 // CXX11: CXXRecordDecl28 // CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'29 // CXX11-NEXT: CompoundStmt30 // CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__31 // CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()"32 }33#endif // __cplusplus >= 201103L34} // namespace cwg177235 36namespace cwg1779 { // cwg1779: 1437 // __func__ in a function template, member function template, or generic38 // lambda should have a dependent type.39 // CHECK: NamespaceDecl{{.+}}cwg177940 41 template<typename T>42 void FuncTemplate() {43 __func__;44 // CHECK: FunctionDecl{{.+}} FuncTemplate45 // CHECK-NEXT: CompoundStmt46 // CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__47 }48 49 template<typename T>50 class ClassTemplate {51 // CHECK: ClassTemplateDecl{{.+}} ClassTemplate52 void MemFunc() {53 // CHECK: CXXMethodDecl{{.+}} MemFunc 'void (){{.*}}'54 // CHECK-NEXT: CompoundStmt55 // CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__56 __func__;57 }58 void OutOfLineMemFunc();59 };60 61 template <typename T> void ClassTemplate<T>::OutOfLineMemFunc() {62 // CHECK: CXXMethodDecl{{.+}}parent{{.+}} OutOfLineMemFunc 'void (){{.*}}'63 // CHECK-NEXT: CompoundStmt64 // CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__65 __func__;66 }67 68#if __cplusplus >= 201402L69 void contains_generic_lambda() {70 // CXX14: FunctionDecl{{.+}}contains_generic_lambda71 // CXX14: LambdaExpr72 // CXX14: CXXRecordDecl73 // CXX14: CXXMethodDecl{{.+}} operator() 'auto (auto) {{.*}}const'74 // CXX14-NEXT: ParmVarDecl75 // CXX14-NEXT: CompoundStmt76 // CXX14-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__77 (void)[](auto x) {78 __func__;79 };80 }81#endif // __cplusplus >= 201402L82} // namespace cwg177983