Ignore:
Timestamp:
May 1, 2018, 2:07:35 PM (6 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:
f465f0e
Parents:
7b45636
Message:

Remove now-invalid subscript overload from references test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/references.c

    r7b45636 ra02842f  
    4545}
    4646
    47 // --- temporary code needed to make array of references subscript work.
    48 extern "C" {
    49   void ** __index(__attribute__ ((unused)) size_t sizeof_T, __attribute__ ((unused)) size_t alignof_T, void **x, ptrdiff_t y) {
    50     return (void **)((char *)x+y*sizeof(void *));
    51   }
    52   void __ctor(void ***dst, void **src) {
    53     *dst = src;
    54   }
    55 }
    56 __attribute__((alias("__index"))) forall( dtype T | sized(T) ) T && ?[?]( T & * x, ptrdiff_t y );
    57 __attribute__((alias("__ctor"))) forall( dtype DT ) void ?{}( DT & * & dst, DT & * src);
    58 forall( dtype DT ) void ^?{}( DT & * & ) {}
    59 // --- end of temporary code
    60 
    6147int main() {
    6248        int x = 123456, x2 = 789, *p1 = &x, **p2 = &p1, ***p3 = &p2,
     
    6652        *p3 = &p1;                          // change p2
    6753        int y = 0, z = 11, & ar[3] = { x, y, z };    // initialize array of references
    68         &ar[1] = &z;                        // change reference array element
    69         typeof( ar[1] ) p = 3;              // is int, i.e., the type of referenced object
    70         typeof( &ar[1] ) q = &x;            // is int *, i.e., the type of pointer
    71         _Static_assert( sizeof( ar[1] ) == sizeof( int ), "Array type should be int." );   // is true, i.e., the size of referenced object
    72         _Static_assert( sizeof( &ar[1] ) == sizeof( int *), "Address of array should be int *." ); // is true, i.e., the size of a reference
     54        // &ar[1] = &z;                        // change reference array element
     55        // typeof( ar[1] ) p = 3;              // is int, i.e., the type of referenced object
     56        // typeof( &ar[1] ) q = &x;            // is int *, i.e., the type of pointer
     57        // _Static_assert( sizeof( ar[1] ) == sizeof( int ), "Array type should be int." );   // is true, i.e., the size of referenced object
     58        // _Static_assert( sizeof( &ar[1] ) == sizeof( int *), "Address of array should be int *." ); // is true, i.e., the size of a reference
    7359
    7460        ((int*&)&r3) = &x;                  // change r1, (&*)**r3
     
    136122// tab-width: 4 //
    137123// End: //
    138 
Note: See TracChangeset for help on using the changeset viewer.