1#include <limits>
2
3enum Enum {
4 enum_case1 = 1,
5 enum_case2 = 2,
6};
7
8enum EnumBool : bool {
9 enum_bool_case1 = false,
10 enum_bool_case2 = true,
11};
12
13enum class ScopedEnum {
14 scoped_enum_case1 = 1,
15 scoped_enum_case2 = 2,
16};
17
18enum class ScopedCharEnum : char {
19 case1 = 1,
20 case2 = 2,
21};
22
23enum class ScopedLongLongEnum : long long {
24 case0 = std::numeric_limits<long long>::min(),
25 case1 = 1,
26 case2 = std::numeric_limits<long long>::max(),
27};
28
29struct A {
30 const static int int_val = 1;
31 const static int int_val_with_address = 2;
32 const static bool bool_val = true;
33
34 const static auto char_max = std::numeric_limits<char>::max();
35 const static auto schar_max = std::numeric_limits<signed char>::max();
36 const static auto uchar_max = std::numeric_limits<unsigned char>::max();
37 const static auto int_max = std::numeric_limits<int>::max();
38 const static auto uint_max = std::numeric_limits<unsigned>::max();
39 const static auto long_max = std::numeric_limits<long>::max();
40 const static auto ulong_max = std::numeric_limits<unsigned long>::max();
41 const static auto longlong_max = std::numeric_limits<long long>::max();
42 const static auto ulonglong_max =
43 std::numeric_limits<unsigned long long>::max();
44 const static auto wchar_max = std::numeric_limits<wchar_t>::max();
45
46 const static auto char_min = std::numeric_limits<char>::min();
47 const static auto schar_min = std::numeric_limits<signed char>::min();
48 const static auto uchar_min = std::numeric_limits<unsigned char>::min();
49 const static auto int_min = std::numeric_limits<int>::min();
50 const static auto uint_min = std::numeric_limits<unsigned>::min();
51 const static auto long_min = std::numeric_limits<long>::min();
52 const static auto ulong_min = std::numeric_limits<unsigned long>::min();
53 const static auto longlong_min = std::numeric_limits<long long>::min();
54 const static auto ulonglong_min =
55 std::numeric_limits<unsigned long long>::min();
56 const static auto wchar_min = std::numeric_limits<wchar_t>::min();
57
58 const static Enum enum_val = enum_case2;
59 const static EnumBool enum_bool_val = enum_bool_case1;
60 const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
61 const static ScopedEnum not_enumerator_scoped_enum_val = static_cast<ScopedEnum>(5);
62 const static ScopedEnum not_enumerator_scoped_enum_val_2 =
63 static_cast<ScopedEnum>(7);
64 const static ScopedCharEnum scoped_char_enum_val = ScopedCharEnum::case2;
65 const static ScopedLongLongEnum scoped_ll_enum_val_neg =
66 ScopedLongLongEnum::case0;
67 const static ScopedLongLongEnum scoped_ll_enum_val =
68 ScopedLongLongEnum::case2;
69};
70
71const int A::int_val_with_address;
72
73struct ClassWithOnlyConstStatic {
74 const static int member = 3;
75};
76
77struct ClassWithConstexprs {
78 constexpr static int member = 2;
79 constexpr static Enum enum_val = enum_case2;
80 constexpr static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
81} cwc;
82
83struct ClassWithEnumAlias {
84 using EnumAlias = ScopedEnum;
85 static constexpr EnumAlias enum_alias = ScopedEnum::scoped_enum_case2;
86
87 using EnumAliasAlias = EnumAlias;
88 static constexpr EnumAliasAlias enum_alias_alias =
89 ScopedEnum::scoped_enum_case1;
90};
91
92namespace ns {
93struct Foo {
94 constexpr static int mem = 10;
95
96 void bar() { return; }
97};
98} // namespace ns
99
100struct Foo {
101 constexpr static int mem = -29;
102};
103
104int func() {
105 Foo f1;
106 ns::Foo f2;
107 f2.bar();
108 return ns::Foo::mem + Foo::mem;
109}
110
111int main() {
112 A a;
113
114 auto char_max = A::char_max;
115 auto schar_max = A::schar_max;
116 auto uchar_max = A::uchar_max;
117 auto int_max = A::int_max;
118 auto uint_max = A::uint_max;
119 auto long_max = A::long_max;
120 auto ulong_max = A::ulong_max;
121 auto longlong_max = A::longlong_max;
122 auto ulonglong_max = A::ulonglong_max;
123 auto wchar_max = A::wchar_max;
124
125 auto char_min = A::char_min;
126 auto schar_min = A::schar_min;
127 auto uchar_min = A::uchar_min;
128 auto int_min = A::int_min;
129 auto uint_min = A::uint_min;
130 auto long_min = A::long_min;
131 auto ulong_min = A::ulong_min;
132 auto longlong_min = A::longlong_min;
133 auto ulonglong_min = A::ulonglong_min;
134 auto wchar_min = A::wchar_min;
135
136 int member_copy = ClassWithOnlyConstStatic::member;
137
138 Enum e = A::enum_val;
139 ScopedEnum se = A::scoped_enum_val;
140 se = A::not_enumerator_scoped_enum_val;
141 ScopedCharEnum sce = A::scoped_char_enum_val;
142 ScopedLongLongEnum sle = A::scoped_ll_enum_val;
143
144 auto enum_alias_val = ClassWithEnumAlias::enum_alias;
145 auto enum_alias_alias_val = ClassWithEnumAlias::enum_alias_alias;
146 auto ret = func();
147
148 return 0; // break here
149}
150

source code of lldb/test/API/lang/cpp/const_static_integral_member/main.cpp