Changes in / [f203a7a:1ba5803]


Ignore:
Location:
src
Files:
1 added
19 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    rf203a7a r1ba5803  
    393393                        if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types
    394394
    395                         // type may involve type variables, so apply type substitution to get temporary variable's actual type.
     395                        // type may involve type variables, so apply type substitution to get temporary variable's actual type,
     396                        // since result type may not be substituted (e.g., if the type does not appear in the parameter list)
    396397                        // Use applyFree so that types bound in function pointers are not substituted, e.g. in forall(dtype T) void (*)(T).
    397                         result = result->clone();
    398398                        env->applyFree( result );
    399399                        ObjectDecl * tmp = ObjectDecl::newObject( "__tmp", result, nullptr );
     
    570570
    571571                        if ( returnDecl ) {
    572                                 UntypedExpr * assign = new UntypedExpr( new NameExpr( "?=?" ) );
    573                                 assign->get_args().push_back( new VariableExpr( returnDecl ) );
    574                                 assign->get_args().push_back( callExpr );
    575                                 // know the result type of the assignment is the type of the LHS (minus the pointer), so
    576                                 // add that onto the assignment expression so that later steps have the necessary information
    577                                 assign->set_result( returnDecl->get_type()->clone() );
    578 
     572                                ApplicationExpr * assign = createBitwiseAssignment( new VariableExpr( returnDecl ), callExpr );
    579573                                Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
    580574                                // move env from callExpr to retExpr
     
    11461140                        assert( ctorExpr->result && ctorExpr->get_result()->size() == 1 );
    11471141
    1148                         // xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary.
    1149                         ObjectDecl * tmp = ObjectDecl::newObject( tempNamer.newName(), ctorExpr->get_result()->clone(), nullptr );
    1150                         declsToAddBefore.push_back( tmp );
    1151 
    11521142                        // xxx - this can be TupleAssignExpr now. Need to properly handle this case.
    11531143                        ApplicationExpr * callExpr = strict_dynamic_cast< ApplicationExpr * > ( ctorExpr->get_callExpr() );
     
    11551145                        ctorExpr->set_callExpr( nullptr );
    11561146                        ctorExpr->set_env( nullptr );
     1147
     1148                        // xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary.
     1149                        ObjectDecl * tmp = ObjectDecl::newObject( tempNamer.newName(), callExpr->args.front()->result->clone(), nullptr );
     1150                        declsToAddBefore.push_back( tmp );
    11571151                        delete ctorExpr;
    11581152
  • src/InitTweak/InitTweak.cc

    rf203a7a r1ba5803  
    1212#include "Parser/LinkageSpec.h"    // for Spec, isBuiltin, Intrinsic
    1313#include "ResolvExpr/typeops.h"    // for typesCompatibleIgnoreQualifiers
     14#include "SymTab/Autogen.h"
    1415#include "SymTab/Indexer.h"        // for Indexer
    1516#include "SynTree/Attribute.h"     // for Attribute
     
    524525        }
    525526
     527        ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src ) {
     528                static FunctionDecl * assign = nullptr;
     529                if ( ! assign ) {
     530                        // temporary? Generate a fake assignment operator to represent bitwise assignments.
     531                        // This operator could easily exist as a real function, but it's tricky because nothing should resolve to this function.
     532                        TypeDecl * td = new TypeDecl( "T", noStorageClasses, nullptr, TypeDecl::Dtype, true );
     533                        assign = new FunctionDecl( "?=?", noStorageClasses, LinkageSpec::Intrinsic, SymTab::genAssignType( new TypeInstType( noQualifiers, td->name, td ) ), nullptr );
     534                }
     535                if ( dynamic_cast< ReferenceType * >( dst->result ) ) {
     536                        dst = new AddressExpr( dst );
     537                } else {
     538                        dst = new CastExpr( dst, new ReferenceType( noQualifiers, dst->result->clone() ) );
     539                }
     540                if ( dynamic_cast< ReferenceType * >( src->result ) ) {
     541                        src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
     542                }
     543                return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
     544        }
     545
    526546        class ConstExprChecker : public Visitor {
    527547        public:
  • src/InitTweak/InitTweak.h

    rf203a7a r1ba5803  
    3535        /// returns the first parameter of a constructor/destructor/assignment function
    3636        ObjectDecl * getParamThis( FunctionType * ftype );
     37
     38        /// generate a bitwise assignment operation.
     39        ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src );
    3740
    3841        /// transform Initializer into an argument list that can be passed to a call expression
  • src/ResolvExpr/PtrsAssignable.cc

    rf203a7a r1ba5803  
    6868
    6969        void PtrsAssignable::visit( __attribute((unused)) VoidType *voidType ) {
    70                 if ( ! dynamic_cast< FunctionType* >( dest ) ) {
    71                         // T * = void * is safe for any T that is not a function type.
    72                         // xxx - this should be unsafe...
    73                         result = 1;
    74                 } // if
     70                // T * = void * is disallowed - this is a change from C, where any
     71                // void * can be assigned or passed to a non-void pointer without a cast.
    7572        }
    7673
  • src/libcfa/concurrency/kernel

    rf203a7a r1ba5803  
    120120#ifdef __CFA_DEBUG__
    121121        // Last function to enable preemption on this processor
    122         char * last_enable;
     122        const char * last_enable;
    123123#endif
    124124};
  • src/libcfa/concurrency/monitor.c

    rf203a7a r1ba5803  
    823823                this.monitor_count = thrd->monitors.size;
    824824
    825                 this.monitors = malloc( this.monitor_count * sizeof( *this.monitors ) );
     825                this.monitors = (monitor_desc **)malloc( this.monitor_count * sizeof( *this.monitors ) );
    826826                for( int i = 0; i < this.monitor_count; i++ ) {
    827827                        this.monitors[i] = thrd->monitors.list[i];
  • src/libcfa/stdhdr/stddef.h

    rf203a7a r1ba5803  
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // stddef.h -- 
    8 // 
     6//
     7// stddef.h --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Mon Jul  4 23:25:26 2016
     
    1212// Last Modified On : Tue Jul  5 20:40:01 2016
    1313// Update Count     : 12
    14 // 
     14//
    1515
    1616extern "C" {
    17 #include_next <stddef.h>                                                                // has internal check for multiple expansion
     17#include_next <stddef.h>                // has internal check for multiple expansion
     18#undef NULL
     19#define NULL 0                          // define NULL as 0 rather than (void*)0 to take advantage of zero_t
    1820} // extern "C"
    1921
  • src/libcfa/stdlib

    rf203a7a r1ba5803  
    7777        //printf( "X8\n" );
    7878        T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );     // C malloc
    79     return memset( ptr, (int)fill, sizeof(T) );                 // initial with fill value
     79    return (T *)memset( ptr, (int)fill, sizeof(T) );                    // initial with fill value
    8080} // alloc
    8181
     
    8787        //printf( "X10\n" );
    8888        T * ptr = (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
    89     return memset( ptr, (int)fill, dim * sizeof(T) );
     89    return (T *)memset( ptr, (int)fill, dim * sizeof(T) );
    9090} // alloc
    9191
    9292static inline forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim ) {
    9393        //printf( "X11\n" );
    94         return (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
     94        return (T *)(void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
    9595} // alloc
    9696forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill );
     
    103103        //printf( "X14\n" );
    104104    T * ptr = (T *)memalign( align, sizeof(T) );
    105     return memset( ptr, (int)fill, sizeof(T) );
     105    return (T *)memset( ptr, (int)fill, sizeof(T) );
    106106} // align_alloc
    107107
     
    113113        //printf( "X16\n" );
    114114    T * ptr = (T *)memalign( align, dim * sizeof(T) );
    115     return memset( ptr, (int)fill, dim * sizeof(T) );
     115    return (T *)memset( ptr, (int)fill, dim * sizeof(T) );
    116116} // align_alloc
    117117
     
    120120static inline forall( dtype T | sized(T) ) T * memset( T * dest, char c ) {
    121121        //printf( "X17\n" );
    122         return memset( dest, c, sizeof(T) );
     122        return (T *)memset( dest, c, sizeof(T) );
    123123} // memset
    124124extern "C" { void * memcpy( void * dest, const void * src, size_t size ); } // use default C routine for void *
    125125static inline forall( dtype T | sized(T) ) T * memcpy( T * dest, const T * src ) {
    126126        //printf( "X18\n" );
    127         return memcpy( dest, src, sizeof(T) );
     127        return (T *)memcpy( dest, src, sizeof(T) );
    128128} // memcpy
    129129
     
    131131static inline forall( dtype T | sized(T) ) T * memset( T dest[], size_t dim, char c ) {
    132132        //printf( "X19\n" );
    133         return (void *)memset( dest, c, dim * sizeof(T) );      // C memset
     133        return (T *)(void *)memset( dest, c, dim * sizeof(T) ); // C memset
    134134} // memset
    135135static inline forall( dtype T | sized(T) ) T * memcpy( T dest[], const T src[], size_t dim ) {
    136136        //printf( "X20\n" );
    137         return (void *)memcpy( dest, src, dim * sizeof(T) ); // C memcpy
     137        return (T *)(void *)memcpy( dest, src, dim * sizeof(T) ); // C memcpy
    138138} // memcpy
    139139
  • src/prelude/prelude.cf

    rf203a7a r1ba5803  
    403403forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT * volatile &, const volatile    DT * );
    404404
    405 forall( dtype DT ) DT *                 ?=?(                 DT *          &,                   void * );
    406 forall( dtype DT ) DT *                 ?=?(                 DT * volatile &,                   void * );
    407 forall( dtype DT ) const DT *           ?=?( const           DT *          &,                   void * );
    408 forall( dtype DT ) const DT *           ?=?( const           DT * volatile &,                   void * );
    409 forall( dtype DT ) const DT *           ?=?( const           DT *          &, const             void * );
    410 forall( dtype DT ) const DT *           ?=?( const           DT * volatile &, const             void * );
    411 forall( dtype DT ) volatile DT *        ?=?(       volatile  DT *          &,                   void * );
    412 forall( dtype DT ) volatile DT *        ?=?(       volatile  DT * volatile &,                   void * );
    413 forall( dtype DT ) volatile DT *        ?=?(       volatile  DT *          &,       volatile    void * );
    414 forall( dtype DT ) volatile DT *        ?=?(       volatile  DT * volatile &,       volatile    void * );
    415 
    416 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT *          &,                   void * );
    417 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT * volatile &,                   void * );
    418 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT *          &, const             void * );
    419 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT * volatile &, const             void * );
    420 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT *          &,       volatile    void * );
    421 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT * volatile &,       volatile    void * );
    422 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT *          &, const volatile    void * );
    423 forall( dtype DT ) const volatile DT *  ?=?( const volatile  DT * volatile &, const volatile    void * );
    424 
    425405forall( dtype DT ) void *                ?=?(                void *          &,                 DT * );
    426406forall( dtype DT ) void *                ?=?(                void * volatile &,                 DT * );
     
    441421forall( dtype DT ) const volatile void * ?=?( const volatile void *          &, const volatile  DT * );
    442422forall( dtype DT ) const volatile void * ?=?( const volatile void * volatile &, const volatile  DT * );
    443 
    444 void *                  ?=?(                void *          &,                void * );
    445 void *                  ?=?(                void * volatile &,                void * );
    446 const void *            ?=?( const          void *          &,                void * );
    447 const void *            ?=?( const          void * volatile &,                void * );
    448 const void *            ?=?( const          void *          &, const          void * );
    449 const void *            ?=?( const          void * volatile &, const          void * );
    450 volatile void *         ?=?(       volatile void *          &,                void * );
    451 volatile void *         ?=?(       volatile void * volatile &,                void * );
    452 volatile void *         ?=?(       volatile void *          &,       volatile void * );
    453 volatile void *         ?=?(       volatile void * volatile &,       volatile void * );
    454 const volatile void *   ?=?( const volatile void *          &,                void * );
    455 const volatile void *   ?=?( const volatile void * volatile &,                void * );
    456 const volatile void *   ?=?( const volatile void *          &, const          void * );
    457 const volatile void *   ?=?( const volatile void * volatile &, const          void * );
    458 const volatile void *   ?=?( const volatile void *          &,       volatile void * );
    459 const volatile void *   ?=?( const volatile void * volatile &,       volatile void * );
    460 const volatile void *   ?=?( const volatile void *          &, const volatile void * );
    461 const volatile void *   ?=?( const volatile void * volatile &, const volatile void * );
    462423
    463424//forall( dtype DT ) DT *                       ?=?(                DT *          &, zero_t );
     
    781742forall( dtype DT ) void ?{}( const volatile  DT *          &, const volatile    DT * );
    782743
    783 forall( dtype DT ) void ?{}(                 DT *          &,                   void * );
    784 forall( dtype DT ) void ?{}( const           DT *          &,                   void * );
    785 forall( dtype DT ) void ?{}( const           DT *          &, const             void * );
    786 forall( dtype DT ) void ?{}(       volatile  DT *          &,                   void * );
    787 forall( dtype DT ) void ?{}(       volatile  DT *          &,       volatile    void * );
    788 
    789 forall( dtype DT ) void ?{}( const volatile  DT *          &,                   void * );
    790 forall( dtype DT ) void ?{}( const volatile  DT *          &, const             void * );
    791 forall( dtype DT ) void ?{}( const volatile  DT *          &,       volatile    void * );
    792 forall( dtype DT ) void ?{}( const volatile  DT *          &, const volatile    void * );
    793 
    794744forall( dtype DT ) void ?{}(                 void *          &,                 DT * );
    795745forall( dtype DT ) void ?{}( const           void *          &,                 DT * );
     
    802752forall( dtype DT ) void ?{}( const volatile void *           &, const volatile  DT * );
    803753
    804 void    ?{}(                void *          &,                void * );
    805 void    ?{}( const          void *          &,                void * );
    806 void    ?{}( const          void *          &, const          void * );
    807 void    ?{}(       volatile void *          &,                void * );
    808 void    ?{}(       volatile void *          &,       volatile void * );
    809 void    ?{}( const volatile void *          &,                void * );
    810 void    ?{}( const volatile void *          &, const          void * );
    811 void    ?{}( const volatile void *          &,       volatile void * );
    812 void    ?{}( const volatile void *          &, const volatile void * );
    813 
    814754//forall( dtype DT ) void ?{}(              DT *          &, zero_t );
    815755//forall( dtype DT ) void ?{}(              DT * volatile &, zero_t );
  • src/tests/.expect/completeTypeError.txt

    rf203a7a r1ba5803  
    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

    rf203a7a r1ba5803  
    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

    rf203a7a r1ba5803  
    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

    rf203a7a r1ba5803  
    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

    rf203a7a r1ba5803  
    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

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

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

    rf203a7a r1ba5803  
    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/tupleVariadic.c

    rf203a7a r1ba5803  
    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

    rf203a7a r1ba5803  
    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.