Changeset f5478c8 for src/tests


Ignore:
Timestamp:
Nov 24, 2017, 8:57:00 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
2b716ec
Parents:
50abab9 (diff), 3de176d (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

Location:
src/tests
Files:
1 added
12 edited

Legend:

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

    r50abab9 rf5478c8  
    55  charAlternatives are:
    66Cost ( 1, 0, 0, 0 ): Cast of:
    7      Variable Expression: f: signed int
     7     Variable Expression: f: function
     8       accepting unspecified arguments
     9     ... returning nothing
     10
    811   ... to:
    912     char
     
    2326
    2427Cost ( 1, 0, 0, 0 ): Cast of:
    25      Variable Expression: f: function
    26        accepting unspecified arguments
    27      ... returning nothing
    28 
     28     Variable Expression: f: signed int
    2929   ... to:
    3030     char
  • src/tests/.expect/completeTypeError.txt

    r50abab9 rf5478c8  
    1 completeTypeError.c:34:1 error: No reasonable alternatives for expression Applying untyped:
     1completeTypeError.c:33:1 error: No reasonable alternatives for expression Applying untyped:
    22  Name: *?
    33...to:
    44  Name: v
    55
     6completeTypeError.c:34:1 error: No reasonable alternatives for expression Applying untyped:
     7  Name: *?
     8...to:
     9  Name: y
     10
     11completeTypeError.c:35:1 error: No reasonable alternatives for expression Applying untyped:
     12  Name: foo
     13...to:
     14  Name: v
    615
    716completeTypeError.c:36:1 error: No reasonable alternatives for expression Applying untyped:
     
    1019  Name: v
    1120
    12 
    1321completeTypeError.c:37:1 error: No reasonable alternatives for expression Applying untyped:
    1422  Name: quux
    1523...to:
    1624  Name: v
    17 
    1825
    1926completeTypeError.c:58:1 error: No reasonable alternatives for expression Applying untyped:
     
    2229  Name: y
    2330
    24 
    2531completeTypeError.c:59:1 error: No reasonable alternatives for expression Applying untyped:
    2632  Name: quux
    2733...to:
    2834  Name: y
    29 
    3035
    3136completeTypeError.c:60:1 error: No reasonable alternatives for expression Applying untyped:
     
    3439  Name: y
    3540
    36 
    3741completeTypeError.c:72:1 error: No reasonable alternatives for expression Applying untyped:
    3842  Name: baz
     
    4044  Name: z
    4145
    42 
  • src/tests/Makefile.am

    r50abab9 rf5478c8  
    141141typedefRedef-ERR1: typedefRedef.c @CFA_BINDIR@/@CFA_NAME@
    142142        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
     143
     144alloc-ERROR: alloc.c @CFA_BINDIR@/@CFA_NAME@
     145        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
  • src/tests/Makefile.in

    r50abab9 rf5478c8  
    895895        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    896896
     897alloc-ERROR: alloc.c @CFA_BINDIR@/@CFA_NAME@
     898        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
     899
    897900# Tell versions [3.59,3.63) of GNU make to not export all variables.
    898901# Otherwise a system limit (for SysV at least) may be exceeded.
  • src/tests/alloc.c

    r50abab9 rf5478c8  
    3232        // allocation, non-array types
    3333
    34         p = (void *)malloc( sizeof(*p) );                   // C malloc, type unsafe
     34        p = (int *)(void *)malloc( sizeof(*p) );                   // C malloc, type unsafe
    3535        *p = 0xdeadbeef;
    3636        printf( "C   malloc %#x\n", *p );
     
    5454        printf( "\n" );
    5555
    56         p = calloc( dim, sizeof( *p ) );                    // C array calloc, type unsafe
     56        p = (int *)calloc( dim, sizeof( *p ) );                    // C array calloc, type unsafe
    5757        printf( "C   array calloc, fill 0\n" );
    5858        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     
    8383        printf( "\n" );
    8484
    85         p = (void *)realloc( p, dim * sizeof(*p) );         // C realloc
     85        p = (int *)(void *)realloc( p, dim * sizeof(*p) );         // C realloc
    8686        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    8787        printf( "C   realloc\n" );
     
    256256        stp = malloc();
    257257        printf( "\nSHOULD FAIL\n" );
     258#ifdef ERR1
    258259        p = alloc( stp, dim * sizeof(*stp) );
    259260        p = memset( stp, 10 );
    260261        p = memcpy( &st1, &st );
     262#endif
    261263} // main
    262264
  • src/tests/completeTypeError.c

    r50abab9 rf5478c8  
    1212        void *v;
    1313
    14         // A * x;
    15         // A * y;
    16         // B * x;
    17         // B * z;
     14        A * x;
     15        A * y;
     16        B * x;
     17        B * z;
    1818
    1919        // okay
    2020        *i;
    21         // *x; // picks B
    22         // *z;
     21        *x; // picks B
     22        *z;
    2323        foo(i);
    2424        bar(i);
     
    2929        bar(v);
    3030        qux(v);
    31         foo(v); // questionable, but works at the moment for C compatibility
    3231
    3332        // bad
    3433        *v;
    35         // *y;
     34        *y;
     35        foo(v);
    3636        baz(v);
    3737        quux(v);
  • src/tests/dtor-early-exit.c

    r50abab9 rf5478c8  
    2222
    2323struct A {
    24         char * name;
     24        const char * name;
    2525        int * x;
    2626};
  • src/tests/init_once.c

    r50abab9 rf5478c8  
    7272        insert( &constructed, &x );
    7373
    74         x.x = malloc(sizeof(int));
     74        x.x = (int *)malloc(sizeof(int));
    7575}
    7676
  • src/tests/multiDimension.c

    r50abab9 rf5478c8  
    77  printf("default constructing\n");
    88  (this.a){ 123 };
    9   this.ptr = malloc(sizeof(int));
     9  this.ptr = (int *)malloc(sizeof(int));
    1010}
    1111
     
    1313  printf("copy constructing\n");
    1414  (this.a){ other.a };
    15   this.ptr = malloc(sizeof(int));
     15  this.ptr = (int *)malloc(sizeof(int));
    1616}
    1717
     
    1919  printf("constructing with %d\n", a);
    2020  (this.a){ a };
    21   this.ptr = malloc(sizeof(int));
     21  this.ptr = (int *)malloc(sizeof(int));
    2222}
    2323
  • src/tests/polymorphism.c

    r50abab9 rf5478c8  
    1414//
    1515
     16#include <assert.h>
     17#include <inttypes.h>
     18
    1619forall(otype T)
    1720T f(T x, T y) {
     
    2427}
    2528
     29forall( otype T, otype U )
     30size_t struct_size( T i, U j ) {
     31        struct S { T i; U j; };
     32        return sizeof(S);
     33}
     34
     35forall( otype T, otype U )
     36size_t union_size( T i, U j ) {
     37        union B { T i; U j; };
     38        return sizeof(B);
     39}
     40
     41// perform some simple operations on aggregates of T and U
     42forall( otype T | { void print(T); int ?==?(T, T); }, otype U | { void print(U); U ?=?(U&, zero_t); } )
     43U foo(T i, U j) {
     44        struct S { T i; U j; };
     45        union B { T i; U j; };
     46
     47        S s;
     48        s.i = i;
     49        assert(s.i == i);
     50
     51        B b;
     52        b.j = 0;
     53        b.i = s.i;
     54        return b.j;
     55}
     56
    2657int main() {
    27         // ensure that x is not changed by the invocation of a polymorphic function
    28         int x = 123;
    29         int y = 456;
    30         int z = f(x, y);
    31         printf("%d %d %d\n", x, y, z);
     58        {
     59                // ensure that x is not changed by the invocation of a polymorphic function
     60                int x = 123;
     61                int y = 456;
     62                int z = f(x, y);
     63                printf("%d %d %d\n", x, y, z);
     64        }
    3265
    33         // explicitly specialize function
    34         int (*f)(int) = ident;
    35         ((int(*)(int))ident);
    36         printf("%d %d\n", f(5), ((int(*)(int))ident)(5));
     66        {
     67                // explicitly specialize function
     68                int (*f)(int) = ident;
     69                ((int(*)(int))ident);
     70                printf("%d %d\n", f(5), ((int(*)(int))ident)(5));
     71        }
     72
     73        {
     74                // test aggregates with polymorphic members
     75                typedef uint32_t x_type;
     76                typedef uint64_t y_type;
     77
     78                x_type x = 3;
     79                y_type y = 3;
     80
     81                struct S {
     82                        x_type f1;
     83                        y_type f2;
     84                };
     85                union U {
     86                        x_type f1;
     87                        y_type f2;
     88                };
     89                // ensure that the size of aggregates with polymorphic members
     90                // matches the size of the aggregates in a monomorphic context
     91                assert( struct_size(x, y) == sizeof(S) );
     92                assert( union_size(x, y) == sizeof(U) );
     93
     94                y_type ?=?(y_type & this, zero_t) {
     95                        this = (int)0;
     96                        return this;
     97                }
     98
     99                void print(x_type x) {
     100                        printf("%"PRIu32"\n", x);
     101                }
     102
     103                void print(y_type y) {
     104                        printf("%"PRIu64"\n", y);
     105                }
     106
     107                y_type ret = foo(x, y);
     108
     109                // duplicate logic from inside of foo to ensure the same results
     110                U u;
     111                u.f2 = 0;
     112                u.f1 = x;
     113                assert(ret == u.f2);
     114        }
    37115}
    38116
  • src/tests/tupleVariadic.c

    r50abab9 rf5478c8  
    7373        [a0, a1, a2, a3] = args;
    7474        a.size = 4;
    75         a.data = malloc(sizeof(int)*a.size);
     75        a.data = (int *)malloc(sizeof(int)*a.size);
    7676        a.data[0] = a0;
    7777        a.data[1] = a1;
  • src/tests/vector/vector_int.c

    r50abab9 rf5478c8  
    2727        vec.last = -1;
    2828        vec.capacity = reserve;
    29         vec.data = malloc( sizeof( int ) * reserve );
     29        vec.data = (int *)malloc( sizeof( int ) * reserve );
    3030}
    3131
     
    3333        vec.last = other.last;
    3434        vec.capacity = other.capacity;
    35         vec.data = malloc( sizeof( int ) * other.capacity );
     35        vec.data = (int *)malloc( sizeof( int ) * other.capacity );
    3636        for (int i = 0; i < vec.last; i++) {
    3737                vec.data[i] = other.data[i];
     
    4545void reserve( vector_int *vec, int reserve ) {
    4646        if ( reserve > vec->capacity ) {
    47                 vec->data = realloc( vec->data, sizeof( int ) * reserve );
     47                vec->data = (int *)realloc( vec->data, sizeof( int ) * reserve );
    4848                vec->capacity = reserve;
    4949        }
     
    5454        if ( vec->last == vec->capacity ) {
    5555                vec->capacity *= 2;
    56                 vec->data = realloc( vec->data, sizeof( int ) * vec->capacity );
     56                vec->data = (int *)realloc( vec->data, sizeof( int ) * vec->capacity );
    5757        }
    5858        vec->data[ vec->last ] = element;
Note: See TracChangeset for help on using the changeset viewer.