source: src/tests/ctor-autogen.c@ bfd4974

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since bfd4974 was c6e6333, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Update autogen test case

  • Property mode set to 100644
File size: 1.0 KB
Line 
1// TODO: add error cases (e.g., use of field constructors for managed types, etc.)
2
3enum Color { R, G, B };
4
5// empty struct/union should have generated ctor/dtors
6union U {};
7struct S {};
8
9struct SimpleUnion {
10 int x;
11 double y;
12 char z;
13};
14
15struct SimpleStruct {
16 int x;
17 double y;
18 char z;
19};
20
21// struct/union with members with generated ctor/dtors should themselves have generated ctor/dtors
22union PopulatedUnion {
23 Color c;
24 U u;
25 S s;
26};
27
28struct PopulatedStruct {
29 Color c;
30 U u;
31 S s;
32};
33
34forall(otype T)
35T identity(T x) { return x; }
36
37// can identity e if only sized or only the assertion, but the combination breaks...
38// forall(dtype T | sized(T) | { void ?{}(T &); })
39// void identity(T x) { }
40
41int main() {
42 S s;
43 U u;
44 Color e;
45
46 // identity(R); // Color should be an otype
47 // identity((Color)e);
48 identity(u); // U should be an otype
49 identity(s); // S should be an otype
50
51 PopulatedStruct ps;
52 PopulatedUnion pu;
53
54 identity(ps); // should recursively be an otype
55 identity(pu); // should recursively be an otype
56}
Note: See TracBrowser for help on using the repository browser.