source: src/tests/tupleAssign.c @ 33a7b6d

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 33a7b6d was 33a7b6d, checked in by Rob Schluntz <rschlunt@…>, 6 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: 1.6 KB
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// tupleAssign.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
16int main() {
17        {
18                // test multiple assignment and cascading assignment
19                int u = 5, v = 6, x = 10, y = 11;
20                [int, int] z = [100, 200];
21
22                // swap x, y and store the new [x, y] in [u, v] and in z;
23                printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z);
24                z = [u, v] = [x, y] = [y, x];
25                printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z);
26
27                // shuffle elements -- v = z.0, z.0 = z.1, z.1 = u, u = v
28                [v, z, u] = [z, u, v];
29                printf("u=%d v=%d z=[%d, %d]\n", u, v, z);
30
31                // multiple assignment with tuple expression on right
32                z = [111, 222];
33                [u, v] = [123, 456];
34                printf("u=%d v=%d z=[%d, %d]\n", u, v, z);
35        }
36
37        {
38                // test mass assignment
39                double d = 0.0;
40                int i = 0;
41                char c = '\0';
42                struct X {
43                        int z;
44                } x;
45                X ?=?(X * x, double d) {}
46                [int, double, int] t;
47
48                // no conversion from X to integral types, so this serves as a santiy
49                // check that as long as this compiles, ?=?(_, x) is not generated.
50                [t, x, d, i, c, x] = (double)-2153.12;
51                printf("d=%lg i=%d c=%d t=[%d, %lg, %d]\n", d, i, (int)c, t);
52                [x, c, i, d, x, t] = (double)-2153.12;
53                printf("d=%lg i=%d c=%d t=[%d, %lg, %d]\n", d, i, (int)c, t);
54        }
55}
56
57// Local Variables: //
58// tab-width: 4 //
59// End: //
Note: See TracBrowser for help on using the repository browser.