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