1#include <stdio.h>
2
3class Task {
4public:
5 int id;
6 Task *next;
7 enum {
8 TASK_TYPE_1,
9 TASK_TYPE_2
10 } type;
11 // This struct is anonymous b/c it does not have a name
12 // and it is not unnamed class.
13 // Anonymous classes are a GNU extension.
14 struct {
15 int y;
16 };
17 // This struct is an unnamed class see [class.pre]p1
18 // http://eel.is/c++draft/class#pre-1.sentence-6
19 struct {
20 int x;
21 } my_type_is_nameless;
22 struct name {
23 int x;
24 enum E : int {} e;
25 enum E2 {} e2;
26 } my_type_is_named;
27 enum E : unsigned char {} e;
28 union U {
29 } u;
30 static constexpr long static_constexpr_field = 47;
31 static constexpr bool static_constexpr_bool_field = true;
32 static int static_mutable_field;
33 Task(int i, Task *n):
34 id(i),
35 next(n),
36 type(TASK_TYPE_1)
37 {}
38};
39int Task::static_mutable_field = 42;
40
41template <unsigned Value> struct PointerInfo {
42 enum Masks1 { pointer_mask };
43 enum class Masks2 { pointer_mask };
44};
45
46template <unsigned Value, typename InfoType = PointerInfo<Value>>
47struct Pointer {};
48
49enum EnumType {};
50enum class ScopedEnumType {};
51enum class EnumUChar : unsigned char {};
52
53struct alignas(128) OverAlignedStruct {};
54OverAlignedStruct over_aligned_struct;
55
56struct WithNestedTypedef {
57 typedef int TheTypedef;
58};
59WithNestedTypedef::TheTypedef typedefed_value;
60
61int main (int argc, char const *argv[])
62{
63 Task *task_head = new Task(-1, NULL);
64 Task *task1 = new Task(1, NULL);
65 Task *task2 = new Task(2, NULL);
66 Task *task3 = new Task(3, NULL); // Orphaned.
67 Task *task4 = new Task(4, NULL);
68 Task *task5 = new Task(5, NULL);
69
70 task_head->next = task1;
71 task1->next = task2;
72 task2->next = task4;
73 task4->next = task5;
74
75 int total = 0;
76 Task *t = task_head;
77 while (t != NULL) {
78 if (t->id >= 0)
79 ++total;
80 t = t->next;
81 }
82 printf(format: "We have a total number of %d tasks\n", total);
83
84 // This corresponds to an empty task list.
85 Task *empty_task_head = new Task(-1, NULL);
86
87 typedef int myint;
88 myint myint_arr[] = {1, 2, 3};
89
90 EnumType enum_type;
91 ScopedEnumType scoped_enum_type;
92 EnumUChar scoped_enum_type_uchar;
93
94 Pointer<3> pointer;
95 PointerInfo<3>::Masks1 mask1 = PointerInfo<3>::Masks1::pointer_mask;
96 PointerInfo<3>::Masks2 mask2 = PointerInfo<3>::Masks2::pointer_mask;
97
98 return 0; // Break at this line
99}
100

source code of lldb/test/API/python_api/type/main.cpp