predefined-expr.cpp
2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// RUN: %clang_cc1 -x c++ -std=c++1y -fblocks -fsyntax-only -triple %itanium_abi_triple -verify %s
// PR16946
// expected-no-diagnostics
auto foo() {
static_assert(sizeof(__func__) == 4, "foo");
static_assert(sizeof(__FUNCTION__) == 4, "foo");
static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "auto foo()");
return 0;
}
auto bar() -> decltype(42) {
static_assert(sizeof(__func__) == 4, "bar");
static_assert(sizeof(__FUNCTION__) == 4, "bar");
static_assert(sizeof(__PRETTY_FUNCTION__) == 10, "int bar()");
return 0;
}
// Within templates.
template <typename T>
int baz() {
static_assert(sizeof(__func__) == 4, "baz");
static_assert(sizeof(__FUNCTION__) == 4, "baz");
static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "int baz() [T = int]");
[]() {
static_assert(sizeof(__func__) == 11, "operator()");
static_assert(sizeof(__FUNCTION__) == 11, "operator()");
static_assert(sizeof(__PRETTY_FUNCTION__) == 50,
"auto baz()::<anonymous class>::operator()() const");
return 0;
}
();
^{
static_assert(sizeof(__func__) == 17, "baz_block_invoke");
static_assert(sizeof(__FUNCTION__) == 17, "baz_block_invoke");
static_assert(sizeof(__PRETTY_FUNCTION__) == 33, "int baz() [T = int]_block_invoke");
}();
#pragma clang __debug captured
{
static_assert(sizeof(__func__) == 4, "baz");
static_assert(sizeof(__FUNCTION__) == 4, "baz");
static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "int baz() [T = int]");
}
return 0;
}
int main() {
static_assert(sizeof(__func__) == 5, "main");
static_assert(sizeof(__FUNCTION__) == 5, "main");
static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()");
[]() {
static_assert(sizeof(__func__) == 11, "operator()");
static_assert(sizeof(__FUNCTION__) == 11, "operator()");
static_assert(sizeof(__PRETTY_FUNCTION__) == 51,
"auto main()::<anonymous class>::operator()() const");
return 0;
}
();
^{
static_assert(sizeof(__func__) == 18, "main_block_invoke");
static_assert(sizeof(__FUNCTION__) == 18, "main_block_invoke");
static_assert(sizeof(__PRETTY_FUNCTION__) == 24, "int main()_block_invoke");
}();
#pragma clang __debug captured
{
static_assert(sizeof(__func__) == 5, "main");
static_assert(sizeof(__FUNCTION__) == 5, "main");
static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()");
#pragma clang __debug captured
{
static_assert(sizeof(__func__) == 5, "main");
static_assert(sizeof(__FUNCTION__) == 5, "main");
static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()");
}
}
[]() {
#pragma clang __debug captured
{
static_assert(sizeof(__func__) == 11, "operator()");
static_assert(sizeof(__FUNCTION__) == 11, "operator()");
static_assert(sizeof(__PRETTY_FUNCTION__) == 51,
"auto main()::<anonymous class>::operator()() const");
}
}
();
baz<int>();
return 0;
}