ADT
arm-eh
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
|
Last change
on this file since f33eab7 was afe2939, checked in by Andrew Beach <ajbeach@…>, 5 years ago |
|
Removed #include <stdio.h> from tests that only use printf.
|
-
Property mode
set to
100644
|
|
File size:
454 bytes
|
| Line | |
|---|
| 1 | // Check that a cycle of polymorphic otype structures can be instancated.
|
|---|
| 2 |
|
|---|
| 3 | forall(otype T)
|
|---|
| 4 | struct func_table;
|
|---|
| 5 |
|
|---|
| 6 | forall(otype U)
|
|---|
| 7 | struct object {
|
|---|
| 8 | func_table(U) * virtual_table;
|
|---|
| 9 | };
|
|---|
| 10 |
|
|---|
| 11 | forall(otype T)
|
|---|
| 12 | struct func_table {
|
|---|
| 13 | void (*object_func)(object(T) *);
|
|---|
| 14 | };
|
|---|
| 15 |
|
|---|
| 16 | void func(object(int) *) {
|
|---|
| 17 | printf("Success!\n");
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | func_table(int) an_instance = { func };
|
|---|
| 21 |
|
|---|
| 22 | int main(int argc, char * argv[]) {
|
|---|
| 23 | object(int) x = { 0p };
|
|---|
| 24 | an_instance.object_func( &x );
|
|---|
| 25 | return 0;
|
|---|
| 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.