source: tests/shortCircuit.cfa @ 62b5940

Last change on this file since 62b5940 was 641707d, checked in by Andrew Beach <ajbeach@…>, 2 months ago

More fixing of warnings. Including another error that slipped through to the build and the rest of the 'easy' fixes on tests not in a directory.

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[200fcb3]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
[641707d]3//
[200fcb3]4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
[641707d]6//
7// shortCircuit.cfa --
8//
[200fcb3]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
[641707d]14//
[200fcb3]15
[641707d]16void g( float ) {}
17void g( int ) {}
[62edde5]18
19void f( int a ) {
[641707d]20        int b = 0;
21        float c = 0;
[62edde5]22        g( a ? b : c );
23        g( a && c );
24        g( a || b );
25}
26
[d541057]27void g() {
[641707d]28        int a = 1;
29        struct Int { int b; } a = { 0 };
[0f35657]30        if ( a ) {
[d541057]31                while ( a ) {
32                        int *b;
33                        for ( b; a; b ) {
34                        }
35                }
[0f35657]36        }
[641707d]37        // This should never be resolved to.
38        (void)(Int)a;
[d541057]39}
40
[73abe95]41#include <fstream.hfa>
[d541057]42
43struct test_t {
44        int x;
45};
46
[641707d]47int ?!=?( test_t lhs, zero_t ) {
[d541057]48        sout | lhs.x | " ";
49        return lhs.x != 0;
50}
51
[641707d]52int main() {
[200fcb3]53        sout | nlOff;
[d541057]54        test_t true_val, false_val;
55        true_val.x = 1;
56        false_val.x = 0;
57
58        true_val && false_val;
[200fcb3]59        sout | nl;
[d541057]60
61        true_val || false_val;
[200fcb3]62        sout | nl;
[d541057]63
64        false_val && true_val;
[200fcb3]65        sout | nl;
[d541057]66
67        false_val || true_val;
[200fcb3]68        sout | nl;
[d541057]69
[62edde5]70        return 0;
71}
[200fcb3]72
73// Local Variables: //
74// tab-width: 4 //
75// compile-command: "cfa abs.cfa" //
76// End: //
Note: See TracBrowser for help on using the repository browser.