source: tests/poly-d-cycle.cfa @ f1791a4

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since f1791a4 was 91131689, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Polymorphic structure cyclicic definitions are now tested with both otype and dtype.

  • Property mode set to 100644
File size: 474 bytes
Line 
1// Check that a cycle of polymorphic dtype structures can be instancated.
2
3#include <stdio.h>
4
5forall(dtype T)
6struct func_table;
7
8forall(dtype U)
9struct object {
10        func_table(U) * virtual_table;
11};
12
13forall(dtype T)
14struct func_table {
15        void (*object_func)(object(T) *);
16};
17
18void func(object(int) *) {
19        printf("Success!\n");
20}
21
22func_table(int) an_instance = { func };
23
24int main(int argc, char * argv[]) {
25        object(int) x = { 0p };
26        an_instance.object_func( &x );
27        return 0;
28}
Note: See TracBrowser for help on using the repository browser.