Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/tuplePolymorphism.c

    rebb5ed9 rf7e749f  
    1414//
    1515
    16 // packed is needed so that structs are not passed with the same alignment as function arguments
    17 __attribute__((packed)) struct A {
    18   double x;
    19   char y;
    20   double z;
    21 };
    22 
    23 __attribute__((packed)) struct B {
    24   long long x;
    25   char y;
    26   long long z;
    27 };
    28 
    29 // ensure that f is a viable candidate for g, even though its parameter structure does not exactly match
    30 [A] f([A, B] x, B y) { printf("%g %c %g %lld %c %lld %lld %c %lld\n", x.0.[x,y,z], x.1.[x,y,z], y.[x,y,z]); return x.0; }
    31 forall(otype T, otype U | { T f(T, U, U); })
    32 void g(T x, U y) { f(x, y, y); }
    33 
    34 // add two triples
    3516forall(otype T | { T ?+?(T, T); })
    3617[T, T, T] ?+?([T, T, T] x, [T, T, T] y) {
     
    5940  [x1, x2, x3] = zzz+zzz;
    6041  printf("%d %g %d\n", x1, x2, x3);
    61 
    62   // ensure non-matching assertions are specialized correctly
    63   g((A){ 1.21, 'x', 10.21}, (B){ 1111LL, 'v', 54385938LL });
    6442}
    6543
Note: See TracChangeset for help on using the changeset viewer.