source: tests/ifwhileCtl.c @ 37fe352

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

Moved up many directories in source

  • Property mode set to 100644
File size: 1.6 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2017 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// ifwhileCtl.c --
8//
9// Author           : Peter A. Buhr
10// Created On       : Sat Aug 26 10:13:11 2017
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Jun  6 17:15:09 2018
13// Update Count     : 21
14//
15
16#include <fstream>
17
18int f( int r ) { return r; }
19
20int main( void ) {
21        int x = 4, y = 3;
22
23        if ( int x = 1 ) {
24                sout | "x != 0 correct" | endl;
25        } else {
26                sout | "x == 0 incorrect" | endl;
27        } // if
28
29        if ( int x = 4, y = 0 ) {
30                sout | "x != 0 && y != 0 incorrect" | endl;
31        } else if ( int x = 4, y = 1 ) {
32                sout | "x != 0 && y != 0 correct" | endl;
33        } else {
34                sout | "x == 0 || y == 0 incorrect" | endl;
35        } // if
36
37        if ( int x = 5, y = f( x ); x == y ) {
38                sout | "x == y correct" | endl;
39        } else {
40                sout | "x != y incorrect" | endl;
41        } // if
42
43        if ( struct S { int i; } s = { 3 }; s.i < 4 ) {
44                S s1;
45                sout | "s.i < 4 correct" | endl;
46        } else {
47                S s1;
48                sout | "s.i >= 4 incorrect" | endl;
49        } // if
50
51        while ( int x = 1 ) {
52                sout | "x != 0 correct" | endl;
53                break;
54        } // while
55
56        while ( int x = 4, y = 0 ) {
57                sout | "x != 0 && y != 0 incorrect" | endl;
58        } // while
59
60        while ( int x = 5, y = f( x ); x == y ) {
61                sout | "x == y correct" | endl;
62                break;
63        } // while
64
65        while ( struct S { int i; } s = { 3 }; s.i < 4 ) {
66                S s1;
67                sout | "s.i < 4 correct" | endl;
68                break;
69        } // while
70} // main
71
72// Local Variables: //
73// tab-width: 4 //
74// compile-command: "cfa ifwhileCtl.c" //
75// End: //
Note: See TracBrowser for help on using the repository browser.