summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/predefined-expr.cpp
blob: e203dd4be8fd8288b352a77034e5f125730e3968 (plain)
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
// RUN: %clang_cc1 -std=c++1y -fblocks -fsyntax-only -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;
}

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;
  }
  ();

  ^{
    // FIXME: This is obviously wrong.
    static_assert(sizeof(__func__) == 1, "__main_block_invoke");
    static_assert(sizeof(__FUNCTION__) == 1, "__main_block_invoke");
    static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__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");
    }
  }
  ();
}
OpenPOWER on IntegriCloud