source: tests/counter.c @ 5c45fec

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since 5c45fec was bf71cfd, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Moved up many directories in source

  • Property mode set to 100644
File size: 909 bytes
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 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// counter.c --
8//
9// Author           : Aaron B. Moss
10// Created On       : Thu Feb 22 15:27:00 2018
11// Last Modified By : Aaron B. Moss
12// Last Modified On : Thu Feb 22 15:27:00 2018
13// Update Count     : 1
14//
15
16// Tests unified increment/decrement builtin functions.
17// Could be extended for other arithmetic unifications
18
19struct counter { int x; };
20
21counter& ?+=?( counter& c, one_t ) { ++c.x; return c; }
22
23counter& ?-=?( counter& c, one_t ) { --c.x; return c; }
24
25int main() {
26    counter c = { 42 };
27    c += 1;
28    ++c;
29    c++;
30    printf("%d\n", c.x);
31    c -= 1;
32    --c;
33    c--;
34    printf("%d\n", c.x);
35}
36
37// Local Variables: //
38// tab-width: 4 //
39// compile-command: "cfa counter.c" //
40// End: //
Note: See TracBrowser for help on using the repository browser.