source: src/tests/simpleGenericTriple.c @ d9fa60a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d9fa60a was 33a7b6d, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

changed use of formal types to actual types for boxing return parameters and passing type variables, fix bug where generic struct's members would change types when a member is accessed on a concrete instantiation

  • Property mode set to 100644
File size: 858 bytes
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// simpleGenericTriple.c --
8//
9// Author           : Rob Schluntz
10// Created On       : Tue Nov 15 17:24:32 2016
11// Last Modified By : Rob Schluntz
12// Last Modified On : Tue Nov 15 17:27:28 2016
13// Update Count     : 3
14//
15
16forall(otype T)
17struct T3 {
18        T f0, f1, f2;
19};
20
21forall(otype T | { T ?+?(T, T); })
22T3(T) ?+?(T3(T) x, T3(T) y) {
23        T3(T) z = { x.f0+y.f0, x.f1+y.f1, x.f2+y.f2 };
24        return z;
25}
26
27int main() {
28  int x1 = 123, x3 = 456;
29  double x2 = 999.123;
30  struct T3(int) L = { x1, x2, x3 };
31  struct T3(int) R = { 9, 2, 3 };
32  struct T3(int) ret = L+R;
33  printf("%d %d %d\n", ret.f0, ret.f1, ret.f2);
34}
35
36// Local Variables: //
37// tab-width: 4 //
38// End: //
Note: See TracBrowser for help on using the repository browser.