| 1 |
// RUN: %clang_cc1 -std=c++98 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -std=c++11 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11 |
| 3 |
// RUN: %clang_cc1 -std=c++14 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14 |
| 4 |
// RUN: %clang_cc1 -std=c++17 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14 |
| 5 |
// RUN: %clang_cc1 -std=c++20 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14 |
| 6 |
// RUN: %clang_cc1 -std=c++23 %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14 |
| 7 |
// RUN: %clang_cc1 -std=c++2c %s -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14 |
| 8 |
// RUN: %clang_cc1 -std=c++1z %s -fexceptions -fcxx-exceptions -pedantic-errors -triple i386-windows-pc -ast-dump | FileCheck %s --check-prefixes=CHECK,CXX11,CXX14 |
| 9 |
|
| 10 |
namespace cwg1772 { // cwg1772: 14 |
| 11 |
// __func__ in a lambda should name operator(), not the containing function. |
| 12 |
// CHECK: NamespaceDecl{{.+}}cwg1772 |
| 13 |
#if __cplusplus >= 201103L |
| 14 |
auto x = []() { __func__; }; |
| 15 |
// CXX11: LambdaExpr |
| 16 |
// CXX11: CXXRecordDecl |
| 17 |
// CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const' |
| 18 |
// CXX11-NEXT: CompoundStmt |
| 19 |
// CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__ |
| 20 |
// CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()" |
| 21 |
|
| 22 |
void func() { |
| 23 |
// CXX11: FunctionDecl{{.+}} func |
| 24 |
(void)[]() { __func__; }; |
| 25 |
// CXX11-NEXT: CompoundStmt |
| 26 |
// CXX11: LambdaExpr |
| 27 |
// CXX11: CXXRecordDecl |
| 28 |
// CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const' |
| 29 |
// CXX11-NEXT: CompoundStmt |
| 30 |
// CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__ |
| 31 |
// CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()" |
| 32 |
} |
| 33 |
#endif // __cplusplus >= 201103L |
| 34 |
} // namespace cwg1772 |
| 35 |
|
| 36 |
namespace cwg1779 { // cwg1779: 14 |
| 37 |
// __func__ in a function template, member function template, or generic |
| 38 |
// lambda should have a dependent type. |
| 39 |
// CHECK: NamespaceDecl{{.+}}cwg1779 |
| 40 |
|
| 41 |
template<typename T> |
| 42 |
void FuncTemplate() { |
| 43 |
__func__; |
| 44 |
// CHECK: FunctionDecl{{.+}} FuncTemplate |
| 45 |
// CHECK-NEXT: CompoundStmt |
| 46 |
// CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__ |
| 47 |
} |
| 48 |
|
| 49 |
template<typename T> |
| 50 |
class ClassTemplate { |
| 51 |
// CHECK: ClassTemplateDecl{{.+}} ClassTemplate |
| 52 |
void MemFunc() { |
| 53 |
// CHECK: CXXMethodDecl{{.+}} MemFunc 'void (){{.*}}' |
| 54 |
// CHECK-NEXT: CompoundStmt |
| 55 |
// 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: CompoundStmt |
| 64 |
// CHECK-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__ |
| 65 |
__func__; |
| 66 |
} |
| 67 |
|
| 68 |
#if __cplusplus >= 201402L |
| 69 |
void contains_generic_lambda() { |
| 70 |
// CXX14: FunctionDecl{{.+}}contains_generic_lambda |
| 71 |
// CXX14: LambdaExpr |
| 72 |
// CXX14: CXXRecordDecl |
| 73 |
// CXX14: CXXMethodDecl{{.+}} operator() 'auto (auto) {{.*}}const' |
| 74 |
// CXX14-NEXT: ParmVarDecl |
| 75 |
// CXX14-NEXT: CompoundStmt |
| 76 |
// CXX14-NEXT: PredefinedExpr{{.+}} '<dependent type>' lvalue __func__ |
| 77 |
(void)[](auto x) { |
| 78 |
__func__; |
| 79 |
}; |
| 80 |
} |
| 81 |
#endif // __cplusplus >= 201402L |
| 82 |
} // namespace cwg1779 |