Ignore:
Timestamp:
Nov 6, 2017, 10:28:17 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
bbeb908
Parents:
59a0bde (diff), 9f4524b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/polymorphism.c

    r59a0bde r121ac13  
    1616forall(otype T)
    1717T f(T x, T y) {
    18   x = y;
    19   return x;
     18        x = y;
     19        return x;
     20}
     21
     22forall(otype T) T ident(T x) {
     23        return x;
    2024}
    2125
    2226int main() {
    23   // ensure that x is not changed by the invocation of a polymorphic function
    24   int x = 123;
    25   int y = 456;
    26   int z = f(x, y);
    27   printf("%d %d %d\n", x, y, z);
     27        // ensure that x is not changed by the invocation of a polymorphic function
     28        int x = 123;
     29        int y = 456;
     30        int z = f(x, y);
     31        printf("%d %d %d\n", x, y, z);
     32
     33        // explicitly specialize function
     34        int (*f)(int) = ident;
     35        ((int(*)(int))ident);
     36        printf("%d %d\n", f(5), ((int(*)(int))ident)(5));
    2837}
    2938
Note: See TracChangeset for help on using the changeset viewer.