Changeset 2afec66


Ignore:
Timestamp:
Jul 26, 2017, 5:24:33 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, resolv-new, with_gc
Children:
25bd9074
Parents:
8a6cf7e
Message:

Update several tests for references

Location:
src/tests
Files:
19 edited

Legend:

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

    r8a6cf7e r2afec66  
    44to:
    55  char
    6 Alternatives are:        Cost ( 1, 0, 0 ): Cast of:
     6Alternatives are:        Cost ( 1, 0, 0, 0 ): Cast of:
    77          Variable Expression: f: function
    88                accepting unspecified arguments
     
    1818        Environment:
    1919
    20         Cost ( 1, 0, 0 ): Cast of:
     20        Cost ( 1, 0, 0, 0 ): Cast of:
    2121          Variable Expression: f: signed int
    2222
     
    2828        Environment:
    2929
    30         Cost ( 1, 0, 0 ): Cast of:
     30        Cost ( 1, 0, 0, 0 ): Cast of:
    3131          Variable Expression: f: double
    3232
  • src/tests/alloc.c

    r8a6cf7e r2afec66  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
     
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // alloc.c -- 
    8 // 
     7// alloc.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Feb  3 07:56:22 2016
     
    1212// Last Modified On : Fri Jun  2 15:13:03 2017
    1313// Update Count     : 316
    14 // 
     14//
    1515
    1616#include <assert>
    1717extern "C" {
    18 #include <malloc.h>                                                                             // malloc_usable_size
    19 #include <stdint.h>                                                                             // uintptr_t
    20 #include <stdlib.h>                                                                             // posix_memalign
     18#include <malloc.h>                                     // malloc_usable_size
     19#include <stdint.h>                                     // uintptr_t
     20#include <stdlib.h>                                     // posix_memalign
    2121} // extern
    2222#include <fstream>
    23 #include <stdlib>                                                                               // access C malloc, realloc
     23#include <stdlib>                                       // access C malloc, realloc
    2424
    2525int * foo( int * p, int c ) { return p; }
     
    2828
    2929int main( void ) {
    30     size_t dim = 10;
    31     int * p;
     30        size_t dim = 10;
     31        int * p;
    3232        char fill = '\1';
    3333
    3434        // allocation, non-array types
    3535
    36     p = (void *)malloc( sizeof(*p) );                                   // C malloc, type unsafe
     36        p = (void *)malloc( sizeof(*p) );                   // C malloc, type unsafe
    3737        *p = 0xdeadbeef;
    3838        printf( "C   malloc %#x\n", *p );
    39     free( p );
    40 
    41     p = malloc();                                                                               // CFA malloc, type safe
     39        free( p );
     40
     41        p = malloc();                                       // CFA malloc, type safe
    4242        *p = 0xdeadbeef;
    4343        printf( "CFA malloc %#x\n", *p );
    44     free( p );
    45 
    46     p = alloc();                                                                                // CFA alloc, type safe
     44        free( p );
     45
     46        p = alloc();                                        // CFA alloc, type safe
    4747        *p = 0xdeadbeef;
    4848        printf( "CFA alloc %#x\n", *p );
    49     free( p );
    50 
    51     p = alloc( fill );                                                                  // CFA alloc, fill
     49        free( p );
     50
     51        p = alloc( fill );                                  // CFA alloc, fill
    5252        printf( "CFA alloc, fill %08x\n", *p );
    5353
     
    5656        printf( "\n" );
    5757
    58     p = calloc( dim, sizeof( *p ) );                                    // C array calloc, type unsafe
     58        p = calloc( dim, sizeof( *p ) );                    // C array calloc, type unsafe
    5959        printf( "C   array calloc, fill 0\n" );
    6060        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    6161        printf( "\n" );
    62     free( p );
    63 
    64     p = calloc( dim );                                                                  // CFA array calloc, type safe
     62        free( p );
     63
     64        p = calloc( dim );                                  // CFA array calloc, type safe
    6565        printf( "CFA array calloc, fill 0\n" );
    6666        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    6767        printf( "\n" );
    68     free( p );
    69 
    70     p = alloc( dim );                                                                   // CFA array alloc, type safe
     68        free( p );
     69
     70        p = alloc( dim );                                   // CFA array alloc, type safe
    7171        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    7272        printf( "CFA array alloc, no fill\n" );
    7373        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    7474        printf( "\n" );
    75     free( p );
    76 
    77     p = alloc( 2 * dim, fill );                                                 // CFA array alloc, fill
     75        free( p );
     76
     77        p = alloc( 2 * dim, fill );                         // CFA array alloc, fill
    7878        printf( "CFA array alloc, fill %#x\n", fill );
    7979        for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
     
    8585        printf( "\n" );
    8686
    87     p = (void *)realloc( p, dim * sizeof(*p) );                 // C realloc
     87        p = (void *)realloc( p, dim * sizeof(*p) );         // C realloc
    8888        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    8989        printf( "C   realloc\n" );
     
    9191        printf( "\n" );
    9292
    93     p = realloc( p, 2 * dim * sizeof(*p) );                             // CFA realloc
     93        p = realloc( p, 2 * dim * sizeof(*p) );             // CFA realloc
    9494        for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
    9595        printf( "CFA realloc\n" );
     
    102102        printf( "\n" );
    103103
    104     p = alloc( p, dim );                                                                // CFA resize array alloc
     104        p = alloc( p, dim );                                // CFA resize array alloc
    105105        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    106106        printf( "CFA resize alloc\n" );
     
    108108        printf( "\n" );
    109109
    110     p = alloc( p, 2 * dim );                                                    // CFA resize array alloc
     110        p = alloc( p, 2 * dim );                            // CFA resize array alloc
    111111        for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
    112112        printf( "CFA resize array alloc\n" );
     
    114114        printf( "\n" );
    115115
    116     p = alloc( p, dim );                                                                // CFA array alloc
     116        p = alloc( p, dim );                                // CFA array alloc
    117117        printf( "CFA resize array alloc\n" );
    118118        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     
    122122        p = 0;
    123123
    124     p = alloc( p, dim, fill );                                                  // CFA array alloc, fill
     124        p = alloc( p, dim, fill );                          // CFA array alloc, fill
    125125        printf( "CFA resize array alloc, fill\n" );
    126126        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    127127        printf( "\n" );
    128128
    129     p = alloc( p, 2 * dim, fill );                                              // CFA array alloc, fill
     129        p = alloc( p, 2 * dim, fill );                      // CFA array alloc, fill
    130130        printf( "CFA resize array alloc, fill\n" );
    131131        for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    132132        printf( "\n" );
    133133
    134     p = alloc( p, dim, fill );                                                  // CFA array alloc, fill
     134        p = alloc( p, dim, fill );                          // CFA array alloc, fill
    135135        printf( "CFA resize array alloc, fill\n" );
    136136        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] );; }
     
    139139
    140140
    141     struct Struct { int x; double y; };
    142     Struct st, st1, sta[dim], sta1[dim], * stp, * stp1;
     141        struct Struct { int x; double y; };
     142        Struct st, st1, sta[dim], sta1[dim], * stp, * stp1;
    143143
    144144        // alignment, non-array types
     
    146146        enum { Alignment = 128 };
    147147
    148     stp = (memalign( Alignment, sizeof( *stp ) ) ){ 42, 42.5 }; // C memalign
     148        stp = (memalign( Alignment, sizeof( *stp ) ) ){ 42, 42.5 }; // C memalign
    149149        assert( (uintptr_t)stp % Alignment == 0 );
    150150        printf( "C   memalign %d %g\n", stp->x, stp->y );
    151     free( stp );
    152 
    153     stp = (memalign( Alignment )){ 42, 42.5 };                  // CFA memalign
     151        free( stp );
     152
     153        stp = (memalign( Alignment )){ 42, 42.5 };          // CFA memalign
    154154        assert( (uintptr_t)stp % Alignment == 0 );
    155155        printf( "CFA memalign %d %g\n", stp->x, stp->y );
    156     free( stp );
    157 
    158     posix_memalign( (void **)&stp, Alignment, sizeof( *stp ) ); // C posix_memalign
     156        free( stp );
     157
     158        posix_memalign( (void **)&stp, Alignment, sizeof( *stp ) ); // C posix_memalign
    159159        *stp = (Struct){ 42, 42.5 };
    160160        assert( (uintptr_t)stp % Alignment == 0 );
    161161        printf( "CFA posix_memalign %d %g\n", stp->x, stp->y );
    162     free( stp );
    163 
    164     posix_memalign( &stp, Alignment );                                  // CFA posix_memalign
     162        free( stp );
     163
     164        posix_memalign( &stp, Alignment );                  // CFA posix_memalign
    165165        *stp = (Struct){ 42, 42.5 };
    166166        assert( (uintptr_t)stp % Alignment == 0 );
    167167        printf( "CFA posix_memalign %d %g\n", stp->x, stp->y );
    168     free( stp );
    169 
    170     stp = (aligned_alloc( Alignment )){ 42, 42.5 };             // CFA aligned_alloc
     168        free( stp );
     169
     170        stp = (aligned_alloc( Alignment )){ 42, 42.5 };     // CFA aligned_alloc
    171171        assert( (uintptr_t)stp % Alignment == 0 );
    172172        printf( "CFA aligned_alloc %d %g\n", stp->x, stp->y );
    173     free( stp );
    174 
    175     stp = (align_alloc( Alignment )){ 42, 42.5 };               // CFA align_alloc
     173        free( stp );
     174
     175        stp = (align_alloc( Alignment )){ 42, 42.5 };       // CFA align_alloc
    176176        assert( (uintptr_t)stp % Alignment == 0 );
    177177        printf( "CFA align_alloc %d %g\n", stp->x, stp->y );
    178     free( stp );
    179 
    180     stp = align_alloc( Alignment, fill );                               // CFA memalign, fill
     178        free( stp );
     179
     180        stp = align_alloc( Alignment, fill );               // CFA memalign, fill
    181181        assert( (uintptr_t)stp % Alignment == 0 );
    182182        printf( "CFA align_alloc fill %#x %a\n", stp->x, stp->y );
    183     free( stp );
     183        free( stp );
    184184
    185185
     
    187187        printf( "\n" );
    188188
    189     stp = align_alloc( Alignment, dim );                                // CFA array memalign
     189        stp = align_alloc( Alignment, dim );                // CFA array memalign
    190190        assert( (uintptr_t)stp % Alignment == 0 );
    191191        for ( int i = 0; i < dim; i += 1 ) { stp[i] = (Struct){ 42, 42.5 }; }
     
    193193        for ( int i = 0; i < dim; i += 1 ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    194194        printf( "\n" );
    195     free( stp );
    196 
    197     stp = align_alloc( Alignment, dim, fill );                  // CFA array memalign, fill
     195        free( stp );
     196
     197        stp = align_alloc( Alignment, dim, fill );          // CFA array memalign, fill
    198198        assert( (uintptr_t)stp % Alignment == 0 );
    199199        printf( "CFA array align_alloc, fill\n" );
    200200        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); }
    201201        printf( "\n" );
    202     free( stp );
     202        free( stp );
    203203
    204204
     
    206206        printf( "\n" );
    207207
    208     memset( &st, fill );                                                                // CFA memset, type safe
     208        memset( &st, fill );                                // CFA memset, type safe
    209209        printf( "CFA memset %#x %a\n", st.x, st.y );
    210     memcpy( &st1, &st );                                                                // CFA memcpy, type safe
     210        memcpy( &st1, &st );                                // CFA memcpy, type safe
    211211        printf( "CFA memcpy %#x %a\n", st1.x, st1.y );
    212212
     
    215215        printf( "\n" );
    216216
    217     memset( sta, dim, fill );                                                   // CFA array memset, type safe
     217        memset( sta, dim, fill );                           // CFA array memset, type safe
    218218        printf( "CFA array memset\n" );
    219219        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta[i].x, sta[i].y ); }
    220220        printf( "\n" );
    221221
    222     memcpy( sta1, sta, dim );                                                   // CFA array memcpy, type safe
     222        memcpy( sta1, sta, dim );                           // CFA array memcpy, type safe
    223223        printf( "CFA memcpy\n" );
    224224        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }
     
    247247        printf( "\n" );
    248248
    249     float * fp = malloc() + 1;
    250     printf( "pointer arithmetic %d\n", fp == fp - 1 );
    251     free( fp - 1 );
    252 
    253     p = foo( bar( baz( malloc(), 0 ), 0 ), 0 );
     249        float * fp = malloc() + 1;
     250        printf( "pointer arithmetic %d\n", fp == fp - 1 );
     251        free( fp - 1 );
     252
     253        p = foo( bar( baz( malloc(), 0 ), 0 ), 0 );
    254254        *p = 0xdeadbeef;
    255255        printf( "CFA deep malloc %#x\n", *p );
    256     free( p );
     256        free( p );
    257257
    258258        stp = malloc();
    259259        printf( "\nSHOULD FAIL\n" );
    260     p = alloc( stp, dim * sizeof(*stp) );
    261     p = memset( stp, 10 );
    262     p = memcpy( &st1, &st );
     260        p = alloc( stp, dim * sizeof(*stp) );
     261        p = memset( stp, 10 );
     262        p = memcpy( &st1, &st );
    263263} // main
    264264
  • src/tests/avltree/avl.h

    r8a6cf7e r2afec66  
    2323// forall( otype T, ttype Params | { void ?{}(T *, Params); } ) T * new( Params p );
    2424
    25 forall(dtype T | { void ^?{}(T *); })
     25forall(dtype T | { void ^?{}(T &); })
    2626void delete(T * x);
    2727
     
    5959
    6060forall(otype K | Comparable(K), otype V)
    61 void ?{}(tree(K, V) *t, K key, V value);
     61void ?{}(tree(K, V) &t, K key, V value);
    6262
    6363forall(otype K, otype V)
    64 void ^?{}(tree(K, V) * t);
     64void ^?{}(tree(K, V) & t);
    6565
    6666forall(otype K | Comparable(K), otype V)
  • src/tests/avltree/avl1.c

    r8a6cf7e r2afec66  
    33
    44forall(otype K | Comparable(K), otype V)
    5 void ?{}(tree(K, V) *t, K key, V value){
    6   (&t->key) { key };
    7   (&t->value) { value };
    8   t->parent = NULL;
    9   t->left = NULL;
    10   t->right = NULL;
    11   t->balance = 0;
     5void ?{}(tree(K, V) &t, K key, V value){
     6  (t.key) { key };
     7  (t.value) { value };
     8  t.parent = NULL;
     9  t.left = NULL;
     10  t.right = NULL;
     11  t.balance = 0;
    1212}
    1313
    1414forall(otype K, otype V)
    15 void ^?{}(tree(K, V) * t){
    16   delete(t->left);
    17   delete(t->right);
    18   ^(&t->key){};
    19   ^(&t->value){};
     15void ^?{}(tree(K, V) & t){
     16  delete(t.left);
     17  delete(t.right);
     18  ^(t.key){};
     19  ^(t.value){};
    2020}
    2121
     
    2424  // infinite loop trying to resolve ... t = malloc();
    2525  tree(K, V) * t = malloc(sizeof(tree(K,V)));
    26   t { key, value };
     26  (*t){ key, value };
    2727  return t;
    2828}
  • src/tests/dtor-early-exit.c

    r8a6cf7e r2afec66  
    2727
    2828// don't want these called
    29 void ?{}(A * a) { assert( false ); }
    30 void ?{}(A * a, const char * name) { a->name = name; sout | "construct " | name | endl; a->x = (int*)malloc(); }
    31 void ?{}(A * a, const char * name, int * ptr) { assert( false ); }
    32 
    33 A ?=?(A * a, A a) {  sout | "assign " | a->name | " " | a.name; return a; }
    34 void ?{}(A * a, A a) { sout | "copy construct " | a.name | endl; a->x = (int*)malloc(); }
    35 void ^?{}(A * a) { sout | "destruct " | a->name | endl; free(a->x); }
     29void ?{}(A & a) { assert( false ); }
     30void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name | endl; a.x = (int*)malloc(); }
     31void ?{}(A & a, const char * name, int * ptr) { assert( false ); }
     32
     33A ?=?(A & a, A b) {  sout | "assign " | a.name | " " | b.name; return a; }
     34void ?{}(A & a, A b) { sout | "copy construct " | b.name | endl; a.x = (int*)malloc(); }
     35void ^?{}(A & a) { sout | "destruct " | a.name | endl; free(a.x); }
    3636
    3737// test returns
  • src/tests/globals.c

    r8a6cf7e r2afec66  
    55};
    66
    7 void ?{}( value_t * this ) { this->value = 22; }
     7void ?{}( value_t & this ) { this.value = 22; }
    88
    99//Standard case
     
    1212};
    1313
    14 void ?{}( g_t * this ) { (&this->val){}; }
     14void ?{}( g_t & this ) { (this.val){}; }
    1515
    1616g_t g;
     
    2525//Inline case
    2626struct gi_t;
    27 void ?{}( gi_t * this );
     27void ?{}( gi_t & this );
    2828
    2929struct gi_t {
     
    3131} gi;
    3232
    33 void ?{}( gi_t * this ) { (&this->val){}; }
     33void ?{}( gi_t & this ) { (this.val){}; }
    3434
    3535//Inline autogen case
     
    4343};
    4444
    45 void ?{}( gs_t * this ) { (&this->val){}; }
     45void ?{}( gs_t & this ) { (this.val){}; }
    4646
    4747static gs_t gs;
     
    5656//Static inline case
    5757struct gsi_t;
    58 void ?{}( gsi_t * this );
     58void ?{}( gsi_t & this );
    5959
    6060static struct gsi_t {
     
    6262} gsi;
    6363
    64 void ?{}( gsi_t * this ) { (&this->val){}; }
     64void ?{}( gsi_t & this ) { (this.val){}; }
    6565
    6666//Static inline autogen case
  • src/tests/init_once.c

    r8a6cf7e r2afec66  
    6060        return -1;
    6161}
    62 void ?{}(array * arr) {
    63         memset(arr->elems, 0, sizeof(arr->elems));
    64         arr->length = 0;
     62void ?{}(array & arr) {
     63        memset(arr.elems, 0, sizeof(arr.elems));
     64        arr.length = 0;
    6565}
    6666array constructed;
    6767array destructed;
    6868
    69 void ?{}(init_once * x) {
    70         assert( find( &constructed, x ) == -1 );
    71         remove( &destructed, x );
    72         insert( &constructed, x );
     69void ?{}(init_once & x) {
     70        assert( find( &constructed, &x ) == -1 );
     71        remove( &destructed, &x );
     72        insert( &constructed, &x );
    7373
    74         x->x = malloc(sizeof(int));
     74        x.x = malloc(sizeof(int));
    7575}
    7676
    77 void ?{}(init_once * x, init_once other) {
     77void ?{}(init_once & x, init_once other) {
    7878        x{};  // reuse default ctor
    7979}
    8080
    81 void ^?{}(init_once * x) {
    82         assert( find( &destructed, x ) == -1 );
    83         remove( &constructed, x );
    84         insert( &destructed, x );
     81void ^?{}(init_once & x) {
     82        assert( find( &destructed, &x ) == -1 );
     83        remove( &constructed, &x );
     84        insert( &destructed, &x );
    8585
    86         free(x->x);
     86        free(x.x);
    8787}
    8888//*** end setup
     
    125125                                init_once x;
    126126                                init_once y = x;
    127                                 (&x) {}; // ensure this doesn't execute
     127                                x{}; // ensure this doesn't execute
    128128                                break;
    129129                        }
  • src/tests/memberCtors.c

    r8a6cf7e r2afec66  
    33};
    44
    5 void ?{}(WrappedInt * this) {
     5void ?{}(WrappedInt & this) {
    66  printf("constructing int\n");
    7   this->x = 0;
     7  this.x = 0;
    88}
    99
    10 void ?{}(WrappedInt * this, WrappedInt other) {
     10void ?{}(WrappedInt & this, WrappedInt other) {
    1111  printf("copy constructing int: %d\n", other.x);
    12   this->x = other.x;
     12  this.x = other.x;
    1313}
    1414
    15 void ?{}(WrappedInt * this, int x) {
     15void ?{}(WrappedInt & this, int x) {
    1616  printf("constructing int: %d\n", x);
    17   this->x = x;
     17  this.x = x;
    1818}
    1919
    20 void ^?{}(WrappedInt * this) {
    21   printf("destructing int: %d\n", this->x);
     20void ^?{}(WrappedInt & this) {
     21  printf("destructing int: %d\n", this.x);
    2222}
    2323
    24 void ?=?(WrappedInt * this, int x) {
    25   printf("assigning int: %d %d\n", this->x, x);
    26   this->x = x;
     24void ?=?(WrappedInt & this, int x) {
     25  printf("assigning int: %d %d\n", this.x, x);
     26  this.x = x;
    2727}
    2828
     
    3131};
    3232
    33 void ?{}(A * a) {
     33void ?{}(A & a) {
    3434  // currently must define default ctor, since there's no "= default" syntax
    3535}
    3636
    37 void ?{}(A * a, int x) {
     37void ?{}(A & a, int x) {
    3838  printf("begin construct A\n");
    39   printf("construct a->x\n");
    40   (&a->x){ x+999 };
    41   printf("assign a->y\n");
    42   a->y = 0; // not a constructor - default constructor will be inserted
     39  printf("construct a.x\n");
     40  (a.x){ x+999 };
     41  printf("assign a.y\n");
     42  a.y = 0; // not a constructor - default constructor will be inserted
    4343  printf("end construct A\n");
    4444} // z never constructed - will be automatically default constructed
    4545
    46 void ?{}(A * this, A other) {
     46void ?{}(A & this, A other) {
    4747  printf("begin copy construct A\n");
    48   printf("copy construct this->x\n");
    49   (&this->x){ other.x };
    50   printf("assign this->y\n");
    51   this->y = other.y; // not a constructor - copy constructor will be inserted
     48  printf("copy construct this.x\n");
     49  (this.x){ other.x };
     50  printf("assign this.y\n");
     51  this.y = other.y; // not a constructor - copy constructor will be inserted
    5252  printf("end copy construct A\n");
    5353} // z never constructed - will be automatically copy constructed
    5454
    55 A ?=?(A * this, A other) {
     55A ?=?(A & this, A other) {
    5656  printf("begin ?=? A\n");
    57   this->x = other.x;
    58   this->y = other.y;
    59   this->z = other.z;
     57  this.x = other.x;
     58  this.y = other.y;
     59  this.z = other.z;
    6060  printf("end ?=? A\n");
    61   return *this;
     61  return this;
    6262}
    6363
     
    6666};
    6767
    68 void ?{}(B * b) {
     68void ?{}(B & b) {
    6969  printf("begin construct B\n");
    70   printf("assign b->a2\n");
    71   b->a2 = (A) { 2 };
    72   printf("construct b->a1\n");
    73   (&b->a1){ 1 };
     70  printf("assign b.a2\n");
     71  b.a2 = (A) { 2 };
     72  printf("construct b.a1\n");
     73  (b.a1){ 1 };
    7474#ifdef ERR1
    75   (&b->a2){ b->a3 }; // error, b->a2 was used previously but is explicitly constructed
     75  (b.a2){ b.a3 }; // error, b->a2 was used previously but is explicitly constructed
    7676#endif
    7777  printf("end construct B\n");
    7878} // a2, a3 never constructed - will be automatically default constructed
    7979
    80 void ^?{}(B * b) {
    81   b->a2 = (A) { 0 };
    82   ^(&b->a1){};
     80void ^?{}(B & b) {
     81  b.a2 = (A) { 0 };
     82  ^(b.a1){};
    8383} // a2, a3 never destructed - will be automatically destructed
    8484
  • src/tests/multiDimension.c

    r8a6cf7e r2afec66  
    44};
    55
    6 void ?{}(X * this) {
     6void ?{}(X & this) {
    77  printf("default constructing\n");
    8   (&this->a){ 123 };
    9   this->ptr = malloc(sizeof(int));
     8  (this.a){ 123 };
     9  this.ptr = malloc(sizeof(int));
    1010}
    1111
    12 void ?{}(X * this, X other) {
     12void ?{}(X & this, X other) {
    1313  printf("copy constructing\n");
    14   (&this->a){ other.a };
    15   this->ptr = malloc(sizeof(int));
     14  (this.a){ other.a };
     15  this.ptr = malloc(sizeof(int));
    1616}
    1717
    18 void ?{}(X * this, int a) {
     18void ?{}(X & this, int a) {
    1919  printf("constructing with %d\n", a);
    20   (&this->a){ a };
    21   this->ptr = malloc(sizeof(int));
     20  (this.a){ a };
     21  this.ptr = malloc(sizeof(int));
    2222}
    2323
    24 void ^?{}(X * this) {
     24void ^?{}(X & this) {
    2525  printf("destructing\n");
    26   free(this->ptr);
     26  free(this.ptr);
    2727}
    2828
    29 X ?=?(X * this, X other) {
    30   this->a = other.a;
    31   return *this;
     29X ?=?(X & this, X other) {
     30  this.a = other.a;
     31  return this;
    3232}
    3333
  • src/tests/operators.c

    r8a6cf7e r2afec66  
    1111}
    1212
    13 int ?=?( int *a, int b ) {
     13int ?=?( int &a, int b ) {
    1414        return 0;
    1515}
  • src/tests/preempt.c

    r8a6cf7e r2afec66  
    1616};
    1717
    18 void ?{}( worker_t * this, int value ) {
    19         this->value = value;
     18void ?{}( worker_t & this, int value ) {
     19        this.value = value;
    2020}
    2121
  • src/tests/rational.c

    r8a6cf7e r2afec66  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
     6//
    77// rational.c -- test rational number package
    8 // 
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Mon Mar 28 08:43:12 2016
     
    1212// Last Modified On : Wed May 17 15:46:35 2017
    1313// Update Count     : 65
    14 // 
     14//
    1515
    1616#include <rational>
     
    2020
    2121// UNNECESSARY, FIX ME
    22 void ?{}( int * this ) { *this = 0; }
    23 void ?{}( int * this, zero_t ) { *this = 0; }
    24 void ?{}( int * this, one_t ) { *this = 1; }
     22void ?{}( int & this ) { this = 0; }
     23void ?{}( int & this, zero_t ) { this = 0; }
     24void ?{}( int & this, one_t ) { this = 1; }
    2525double convert( int i ) { return (double)i; }
    2626int convert( double d ) { return (int)d; }
  • src/tests/sched-int-barge.c

    r8a6cf7e r2afec66  
    1919};
    2020
    21 void ?{} ( global_data_t * this ) {
    22         this->done = false;
    23         this->counter = 0;
    24         this->state = BARGE;
     21void ?{} ( global_data_t & this ) {
     22        this.done = false;
     23        this.counter = 0;
     24        this.state = BARGE;
    2525
    26         this->do_signal = 6;
    27         this->do_wait1  = 1;
    28         this->do_wait2  = 3;
     26        this.do_signal = 6;
     27        this.do_wait1  = 1;
     28        this.do_wait2  = 3;
    2929}
    3030
    31 void ^?{} ( global_data_t * this ) {}
     31void ^?{} ( global_data_t & this ) {}
    3232
    3333global_t globalA;
  • src/tests/sched-int-disjoint.c

    r8a6cf7e r2afec66  
    1414
    1515monitor global_data_t;
    16 void ?{}( global_data_t * this );
    17 void ^?{} ( global_data_t * this );
     16void ?{}( global_data_t & this );
     17void ^?{} ( global_data_t & this );
    1818
    1919monitor global_data_t {
     
    2626volatile bool all_done;
    2727
    28 void ?{}( global_data_t * this ) {
    29         this->counter == 0;
    30         this->state = BARGE;
     28void ?{}( global_data_t & this ) {
     29        this.counter == 0;
     30        this.state = BARGE;
    3131}
    3232
    33 void ^?{} ( global_data_t * this ) {}
     33void ^?{} ( global_data_t & this ) {}
    3434
    3535//------------------------------------------------------------------------------
  • src/tests/test.py

    r8a6cf7e r2afec66  
    3131# parses the Makefile to find the machine type (32-bit / 64-bit)
    3232def getMachineType():
    33         sh('echo "void ?{}(int*a,int b){}int main(){return 0;}" > .dummy.c')
     33        sh('echo "void ?{}(int&a,int b){}int main(){return 0;}" > .dummy.c')
    3434        ret, out = sh("make .dummy -s", print2stdout=True)
    3535
  • src/tests/tupleAssign.c

    r8a6cf7e r2afec66  
    4848                        int z;
    4949                } x;
    50                 X ?=?(X * x, double d) {}
     50                X ?=?(X & x, double d) {}
    5151                [int, double, int] t;
    5252
  • src/tests/tupleVariadic.c

    r8a6cf7e r2afec66  
    2929}
    3030
    31 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } )
     31forall( dtype T, ttype Params | sized(T) | { void ?{}(T &, Params); } )
    3232T * new(Params p);
    3333
     
    3838
    3939// xxx - eventually this will be collapsed...x
    40 void ?{}(array * a) {
    41         a->size = 0;
    42         a->data = 0;
     40void ?{}(array & a) {
     41        a.size = 0;
     42        a.data = 0;
    4343        printf("called ?{} with no a\n");
    4444}
    4545
    46 void ?{}(array * a, int a0) {
    47         a->size = 1;
    48         a->data = (int*)malloc(sizeof(int)*a->size);
    49         a->data[0] = a0;
     46void ?{}(array & a, int a0) {
     47        a.size = 1;
     48        a.data = (int*)malloc(sizeof(int)*a.size);
     49        a.data[0] = a0;
    5050        printf("called ?{} with a: %d\n", a0);
    5151}
    5252
    53 void ?{}(array * a, int a0, int a1) {
    54         a->size = 2;
    55         a->data = (int*)malloc(sizeof(int)*a->size);
    56         a->data[0] = a0;
    57         a->data[1] = a1;
     53void ?{}(array & a, int a0, int a1) {
     54        a.size = 2;
     55        a.data = (int*)malloc(sizeof(int)*a.size);
     56        a.data[0] = a0;
     57        a.data[1] = a1;
    5858        printf("called ?{} with a: %d %d\n", a0, a1);
    5959}
    6060
    61 void ?{}(array * a, int a0, int a1, int a2) {
    62         a->size = 3;
    63         a->data = (int*)malloc(sizeof(int)*a->size);
    64         a->data[0] = a0;
    65         a->data[1] = a1;
    66         a->data[2] = a2;
     61void ?{}(array & a, int a0, int a1, int a2) {
     62        a.size = 3;
     63        a.data = (int*)malloc(sizeof(int)*a.size);
     64        a.data[0] = a0;
     65        a.data[1] = a1;
     66        a.data[2] = a2;
    6767        printf("called ?{} with a: %d %d %d\n", a0, a1, a2);
    6868}
    6969
    7070// test use of a tuple argument
    71 [void] ?{}(array * a, [int, int, int, int] args) {
     71[void] ?{}(array & a, [int, int, int, int] args) {
    7272        int a0, a1, a2, a3;
    7373        [a0, a1, a2, a3] = args;
    74         a->size = 4;
    75         a->data = malloc(sizeof(int)*a->size);
    76         a->data[0] = a0;
    77         a->data[1] = a1;
    78         a->data[2] = a2;
    79         a->data[3] = a3;
     74        a.size = 4;
     75        a.data = malloc(sizeof(int)*a.size);
     76        a.data[0] = a0;
     77        a.data[1] = a1;
     78        a.data[2] = a2;
     79        a.data[3] = a3;
    8080        printf("called ?{} with a: %d %d %d %d\n", a0, a1, a2, a3);
    8181}
  • src/tests/vector/vector_int.c

    r8a6cf7e r2afec66  
    2020#define DEFAULT_CAPACITY 20
    2121
    22 void ?{}( vector_int * vec ) {
     22void ?{}( vector_int & vec ) {
    2323        vec { DEFAULT_CAPACITY };
    2424}
    2525
    26 void ?{}( vector_int * vec, int reserve ) {
    27         vec->last = -1;
    28         vec->capacity = reserve;
    29         vec->data = malloc( sizeof( int ) * reserve );
     26void ?{}( vector_int & vec, int reserve ) {
     27        vec.last = -1;
     28        vec.capacity = reserve;
     29        vec.data = malloc( sizeof( int ) * reserve );
    3030}
    3131
    32 void ?{}( vector_int * vec, vector_int other ) {
    33         vec->last = other.last;
    34         vec->capacity = other.capacity;
    35         vec->data = malloc( sizeof( int ) * other.capacity );
    36         for (int i = 0; i < vec->last; i++) {
    37                 vec->data[i] = other.data[i];
     32void ?{}( vector_int & vec, vector_int other ) {
     33        vec.last = other.last;
     34        vec.capacity = other.capacity;
     35        vec.data = malloc( sizeof( int ) * other.capacity );
     36        for (int i = 0; i < vec.last; i++) {
     37                vec.data[i] = other.data[i];
    3838        }
    3939}
    4040
    41 void ^?{}( vector_int * vec ) {
     41void ^?{}( vector_int & vec ) {
    4242        free( vec->data );
    4343}
  • src/tests/vector/vector_int.h

    r8a6cf7e r2afec66  
    2525} vector_int;
    2626
    27 void ?{}( vector_int * );                                                               // allocate vector with default capacity
    28 void ?{}( vector_int *, int reserve );          // allocate vector with specified capacity
    29 void ?{}( vector_int * vec, vector_int other ); // copy constructor
    30 void ^?{}( vector_int * );                                                              // deallocate vector's storage
     27void ?{}( vector_int & );                                                               // allocate vector with default capacity
     28void ?{}( vector_int &, int reserve );          // allocate vector with specified capacity
     29void ?{}( vector_int & vec, vector_int other ); // copy constructor
     30void ^?{}( vector_int & );                                                              // deallocate vector's storage
    3131
    3232void reserve( vector_int *vec, int reserve );                   // reserve more capacity
Note: See TracChangeset for help on using the changeset viewer.