source:
tests/shortCircuit.cfa
@
5f210c0
Last change on this file since 5f210c0 was 200fcb3, checked in by , 6 years ago | |
---|---|
|
|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[200fcb3] | 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 | // shortCircuit.cfa -- | |
8 | // | |
9 | // Author : Peter A. Buhr | |
10 | // Created On : Thu Jan 28 18:26:16 2016 | |
11 | // Last Modified By : Peter A. Buhr | |
12 | // Last Modified On : Tue Dec 4 18:26:05 2018 | |
13 | // Update Count : 4 | |
14 | // | |
15 | ||
[10dc7491] | 16 | void g( float f ) {} |
17 | void g( int i ) {} | |
[62edde5] | 18 | |
19 | void f( int a ) { | |
20 | int b; | |
21 | float c; | |
22 | g( a ? b : c ); | |
23 | g( a && c ); | |
24 | g( a || b ); | |
25 | } | |
26 | ||
[d541057] | 27 | void g() { |
[0f35657] | 28 | int a; |
29 | struct { int b; } a; | |
30 | if ( a ) { | |
[d541057] | 31 | while ( a ) { |
32 | int *b; | |
33 | for ( b; a; b ) { | |
34 | } | |
35 | } | |
[0f35657] | 36 | } |
[d541057] | 37 | } |
38 | ||
[73abe95] | 39 | #include <fstream.hfa> |
[d541057] | 40 | |
41 | struct test_t { | |
42 | int x; | |
43 | }; | |
44 | ||
45 | int ?!=?( test_t lhs, int rhs ) { | |
46 | sout | lhs.x | " "; | |
47 | return lhs.x != 0; | |
48 | } | |
49 | ||
[200fcb3] | 50 | int main( int argc, char const *argv[] ) { |
51 | sout | nlOff; | |
[d541057] | 52 | test_t true_val, false_val; |
53 | true_val.x = 1; | |
54 | false_val.x = 0; | |
55 | ||
56 | true_val && false_val; | |
[200fcb3] | 57 | sout | nl; |
[d541057] | 58 | |
59 | true_val || false_val; | |
[200fcb3] | 60 | sout | nl; |
[d541057] | 61 | |
62 | false_val && true_val; | |
[200fcb3] | 63 | sout | nl; |
[d541057] | 64 | |
65 | false_val || true_val; | |
[200fcb3] | 66 | sout | nl; |
[d541057] | 67 | |
[62edde5] | 68 | return 0; |
69 | } | |
[200fcb3] | 70 | |
71 | // Local Variables: // | |
72 | // tab-width: 4 // | |
73 | // compile-command: "cfa abs.cfa" // | |
74 | // End: // |
Note: See TracBrowser
for help on using the repository browser.