• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -std=c++1y -fblocks -fsyntax-only -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     // FIXME: This is obviously wrong.
37     static_assert(sizeof(__func__) == 1, "__baz_block_invoke");
38     static_assert(sizeof(__FUNCTION__) == 1, "__baz_block_invoke");
39     static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__baz_block_invoke");
40   }
41   ();
42 
43   #pragma clang __debug captured
44   {
45     static_assert(sizeof(__func__) == 4, "baz");
46     static_assert(sizeof(__FUNCTION__) == 4, "baz");
47     static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "int baz() [T = int]");
48   }
49 
50   return 0;
51 }
52 
main()53 int main() {
54   static_assert(sizeof(__func__) == 5, "main");
55   static_assert(sizeof(__FUNCTION__) == 5, "main");
56   static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()");
57 
58   []() {
59     static_assert(sizeof(__func__) == 11, "operator()");
60     static_assert(sizeof(__FUNCTION__) == 11, "operator()");
61     static_assert(sizeof(__PRETTY_FUNCTION__) == 51,
62                   "auto main()::<anonymous class>::operator()() const");
63     return 0;
64   }
65   ();
66 
67   ^{
68     // FIXME: This is obviously wrong.
69     static_assert(sizeof(__func__) == 1, "__main_block_invoke");
70     static_assert(sizeof(__FUNCTION__) == 1, "__main_block_invoke");
71     static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__main_block_invoke");
72   }
73   ();
74 
75   #pragma clang __debug captured
76   {
77     static_assert(sizeof(__func__) == 5, "main");
78     static_assert(sizeof(__FUNCTION__) == 5, "main");
79     static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()");
80 
81     #pragma clang __debug captured
82     {
83       static_assert(sizeof(__func__) == 5, "main");
84       static_assert(sizeof(__FUNCTION__) == 5, "main");
85       static_assert(sizeof(__PRETTY_FUNCTION__) == 11, "int main()");
86     }
87   }
88 
89   []() {
90     #pragma clang __debug captured
91     {
92       static_assert(sizeof(__func__) == 11, "operator()");
93       static_assert(sizeof(__FUNCTION__) == 11, "operator()");
94       static_assert(sizeof(__PRETTY_FUNCTION__) == 51,
95                     "auto main()::<anonymous class>::operator()() const");
96     }
97   }
98   ();
99 
100   baz<int>();
101 
102   return 0;
103 }
104