source: src/tests/ctor-autogen.c @ 8e138da

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 8e138da was 8e138da, checked in by Rob Schluntz <rschlunt@…>, 4 years ago

Add test case for autogenerated functions

  • Property mode set to 100644
File size: 646 bytes
Line 
1enum Color { R, G, B };
2
3// empty struct/union should have generated ctor/dtors
4union U {};
5struct S {};
6
7// struct/union with members with generated ctor/dtors should themselves have generated ctor/dtors
8union PopulatedUnion {
9        Color c;
10        U u;
11        S s;
12};
13
14struct PopulatedStruct {
15        Color state;
16        U u;
17        S s;
18};
19
20forall(otype T)
21T identity(T x) { return x; }
22
23int main() {
24        S s;
25        U u;
26
27        identity(R);  // Color should be an otype
28        identity(u);  // U should be an otype
29        identity(s);  // S should be an otype
30
31        PopulatedStruct ps;
32        PopulatedUnion pu;
33
34        identity(ps); // should recursively be an otype
35        identity(pu); // should recursively be an otype
36}
Note: See TracBrowser for help on using the repository browser.