Changeset 12db9e4


Ignore:
Timestamp:
Mar 19, 2018, 2:44:19 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
1bdd261, d2034b4
Parents:
55c7577
Message:

Update references test to include rvalue-to-reference conversion

Location:
src/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tests/.expect/references.txt

    r55c7577 r12db9e4  
    2828Destructing a Y
    2929Destructing a Y
     303 3
     313
     323
     333 9 { 1, 7 }, [1, 2, 3]
    3034Destructing a Y
    3135Destructing a Y
  • src/tests/references.c

    r55c7577 r12db9e4  
    8787
    8888        z1 = z2;
     89
     90        // test rvalue-to-reference conversion
     91        {
     92                struct S { double x, y; };
     93                void f( int & i, int & j, S & s, int v[] ) {
     94                        printf("%d %d { %g, %g }, [%d, %d, %d]\n", i, j, s.[x, y], v[0], v[1], v[2]);
     95                }
     96                void g(int & i) { printf("%d\n", i); }
     97                void h(int &&& i) { printf("%d\n", i); }
     98
     99                int &&& r = 3;  // rvalue to reference
     100                int i = r;
     101                printf("%d %d\n", i, r);  // both 3
     102
     103                g( 3 );          // rvalue to reference
     104                h( (int &&&)3 ); // rvalue to reference
     105
     106                int a = 5, b = 4;
     107                f( 3, a + b, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); // two rvalue to reference
     108        }
    89109}
    90110
Note: See TracChangeset for help on using the changeset viewer.