File tree Expand file tree Collapse file tree
cpp/ql/test/library-tests/unions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- | unions.cpp:4:8:4:12 | Entry | struct | |
2- | unions.cpp:13:7:13:11 | Value | struct | union |
3- | unions.cpp:19:8:19:22 | EntryWithMethod | struct | |
1+ | unions.cpp:4:8:4:12 | Entry | Struct |
2+ | unions.cpp:13:7:13:11 | Value | Struct, Union |
3+ | unions.cpp:19:8:19:22 | EntryWithMethod | Struct |
4+ | unions.cpp:27:9:27:20 | MyLocalUnion | LocalUnion, Struct, Union |
5+ | unions.cpp:33:7:33:13 | MyClass | |
6+ | unions.cpp:36:9:36:21 | MyNestedUnion | NestedUnion, Struct, Union |
Original file line number Diff line number Diff line change 11import cpp
22
3- from Class t , string struct , string union
4- where if t instanceof Struct then struct = "struct" else struct = ""
5- and if t instanceof Union then union = "union" else union = ""
6- select t , struct , union
3+ string describe ( Class c )
4+ {
5+ (
6+ c instanceof Struct and
7+ result = "Struct"
8+ ) or (
9+ c instanceof Union and
10+ result = "Union"
11+ ) or (
12+ c instanceof LocalUnion and
13+ result = "LocalUnion"
14+ ) or (
15+ c instanceof NestedUnion and
16+ result = "NestedUnion"
17+ )
18+ }
19+
20+ from Class c
21+ select
22+ c ,
23+ concat ( describe ( c ) , ", " )
Original file line number Diff line number Diff line change @@ -21,3 +21,20 @@ struct EntryWithMethod: Entry {
2121 return i;
2222 }
2323};
24+
25+ void myFunction ()
26+ {
27+ union MyLocalUnion {
28+ int i;
29+ float f;
30+ };
31+ }
32+
33+ class MyClass
34+ {
35+ public:
36+ union MyNestedUnion {
37+ int i;
38+ float f;
39+ };
40+ };
You can’t perform that action at this time.
0 commit comments