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

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since c6e6333 was c6e6333, checked in by Rob Schluntz <rschlunt@…>, 6 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.