Changeset 332e93a for tests/zero_one.cfa


Ignore:
Timestamp:
Feb 4, 2025, 9:18:54 PM (7 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
090b076
Parents:
985ff5f (diff), 1ee74df (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/zero_one.cfa

    r985ff5f r332e93a  
    3939}
    4040
     41void testCompats() {
     42    zero_t zero = 0;
     43    one_t one = 1;
     44
     45    int x = 0;
     46        int xx = zero;
     47
     48        sout | x | xx;
     49
     50        x = xx = 42;
     51        sout | x | xx;
     52
     53        x = 0;
     54        xx = zero;
     55        sout | x | xx;
     56
     57        int y = 1;
     58        int yy = one;
     59
     60        sout | y | yy;
     61
     62        y = yy = 42;
     63        sout | y | yy;
     64
     65        y = 1;
     66        yy = one;
     67        sout | y | yy;
     68
     69        void z_helper( int * p, zero_t z ) {
     70                p = z;  // expect z not reported unused here; expect no missing cast from -Wint-conversion
     71                sout | "zero" | (bool) (p == 0);
     72        }
     73
     74        void z_call( int * p, zero_t z ) {
     75                z_helper(p, z);
     76        }
     77
     78        void o_helper( int * p, one_t o ) {
     79          #ifdef ERR1
     80                p = o;
     81          #else
     82                (void) x;  (void) o;
     83          #endif
     84                sout | "one" | (bool) (p == 0);
     85        }
     86
     87        void o_call( int * p, one_t o ) {
     88                o_helper(p, o);
     89        }
     90
     91        z_call( &x, 0 );
     92        z_call( &x, zero );
     93
     94        o_call( &x, 1 );
     95        o_call( &x, one );
     96}
     97
    4198int main() {
    4299        testOverloads();
    43100        testInitAssignQueryIncrement();
     101        testCompats();
    44102        return 0;
    45103}
Note: See TracChangeset for help on using the changeset viewer.