Changeset 1ba5803
- Timestamp:
- Nov 22, 2017, 5:06:06 PM (7 years ago)
- 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:
- 8dceeb7
- Parents:
- f203a7a (diff), 4d5e57b (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. - Location:
- src
- Files:
-
- 1 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
rf203a7a r1ba5803 393 393 if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types 394 394 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) 396 397 // Use applyFree so that types bound in function pointers are not substituted, e.g. in forall(dtype T) void (*)(T). 397 result = result->clone();398 398 env->applyFree( result ); 399 399 ObjectDecl * tmp = ObjectDecl::newObject( "__tmp", result, nullptr ); … … 570 570 571 571 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 ); 579 573 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 580 574 // move env from callExpr to retExpr … … 1146 1140 assert( ctorExpr->result && ctorExpr->get_result()->size() == 1 ); 1147 1141 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 1152 1142 // xxx - this can be TupleAssignExpr now. Need to properly handle this case. 1153 1143 ApplicationExpr * callExpr = strict_dynamic_cast< ApplicationExpr * > ( ctorExpr->get_callExpr() ); … … 1155 1145 ctorExpr->set_callExpr( nullptr ); 1156 1146 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 ); 1157 1151 delete ctorExpr; 1158 1152 -
src/InitTweak/InitTweak.cc
rf203a7a r1ba5803 12 12 #include "Parser/LinkageSpec.h" // for Spec, isBuiltin, Intrinsic 13 13 #include "ResolvExpr/typeops.h" // for typesCompatibleIgnoreQualifiers 14 #include "SymTab/Autogen.h" 14 15 #include "SymTab/Indexer.h" // for Indexer 15 16 #include "SynTree/Attribute.h" // for Attribute … … 524 525 } 525 526 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 526 546 class ConstExprChecker : public Visitor { 527 547 public: -
src/InitTweak/InitTweak.h
rf203a7a r1ba5803 35 35 /// returns the first parameter of a constructor/destructor/assignment function 36 36 ObjectDecl * getParamThis( FunctionType * ftype ); 37 38 /// generate a bitwise assignment operation. 39 ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src ); 37 40 38 41 /// transform Initializer into an argument list that can be passed to a call expression -
src/ResolvExpr/PtrsAssignable.cc
rf203a7a r1ba5803 68 68 69 69 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. 75 72 } 76 73 -
src/libcfa/concurrency/kernel
rf203a7a r1ba5803 120 120 #ifdef __CFA_DEBUG__ 121 121 // Last function to enable preemption on this processor 122 c har * last_enable;122 const char * last_enable; 123 123 #endif 124 124 }; -
src/libcfa/concurrency/monitor.c
rf203a7a r1ba5803 823 823 this.monitor_count = thrd->monitors.size; 824 824 825 this.monitors = malloc( this.monitor_count * sizeof( *this.monitors ) );825 this.monitors = (monitor_desc **)malloc( this.monitor_count * sizeof( *this.monitors ) ); 826 826 for( int i = 0; i < this.monitor_count; i++ ) { 827 827 this.monitors[i] = thrd->monitors.list[i]; -
src/libcfa/stdhdr/stddef.h
rf203a7a r1ba5803 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // stddef.h -- 8 // 6 // 7 // stddef.h -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Mon Jul 4 23:25:26 2016 … … 12 12 // Last Modified On : Tue Jul 5 20:40:01 2016 13 13 // Update Count : 12 14 // 14 // 15 15 16 16 extern "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 18 20 } // extern "C" 19 21 -
src/libcfa/stdlib
rf203a7a r1ba5803 77 77 //printf( "X8\n" ); 78 78 T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc 79 return memset( ptr, (int)fill, sizeof(T) ); // initial with fill value79 return (T *)memset( ptr, (int)fill, sizeof(T) ); // initial with fill value 80 80 } // alloc 81 81 … … 87 87 //printf( "X10\n" ); 88 88 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) ); 90 90 } // alloc 91 91 92 92 static inline forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim ) { 93 93 //printf( "X11\n" ); 94 return ( void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc94 return (T *)(void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc 95 95 } // alloc 96 96 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ); … … 103 103 //printf( "X14\n" ); 104 104 T * ptr = (T *)memalign( align, sizeof(T) ); 105 return memset( ptr, (int)fill, sizeof(T) );105 return (T *)memset( ptr, (int)fill, sizeof(T) ); 106 106 } // align_alloc 107 107 … … 113 113 //printf( "X16\n" ); 114 114 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) ); 116 116 } // align_alloc 117 117 … … 120 120 static inline forall( dtype T | sized(T) ) T * memset( T * dest, char c ) { 121 121 //printf( "X17\n" ); 122 return memset( dest, c, sizeof(T) );122 return (T *)memset( dest, c, sizeof(T) ); 123 123 } // memset 124 124 extern "C" { void * memcpy( void * dest, const void * src, size_t size ); } // use default C routine for void * 125 125 static inline forall( dtype T | sized(T) ) T * memcpy( T * dest, const T * src ) { 126 126 //printf( "X18\n" ); 127 return memcpy( dest, src, sizeof(T) );127 return (T *)memcpy( dest, src, sizeof(T) ); 128 128 } // memcpy 129 129 … … 131 131 static inline forall( dtype T | sized(T) ) T * memset( T dest[], size_t dim, char c ) { 132 132 //printf( "X19\n" ); 133 return ( void *)memset( dest, c, dim * sizeof(T) ); // C memset133 return (T *)(void *)memset( dest, c, dim * sizeof(T) ); // C memset 134 134 } // memset 135 135 static inline forall( dtype T | sized(T) ) T * memcpy( T dest[], const T src[], size_t dim ) { 136 136 //printf( "X20\n" ); 137 return ( void *)memcpy( dest, src, dim * sizeof(T) ); // C memcpy137 return (T *)(void *)memcpy( dest, src, dim * sizeof(T) ); // C memcpy 138 138 } // memcpy 139 139 -
src/prelude/prelude.cf
rf203a7a r1ba5803 403 403 forall( dtype DT ) const volatile DT * ?=?( const volatile DT * volatile &, const volatile DT * ); 404 404 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 425 405 forall( dtype DT ) void * ?=?( void * &, DT * ); 426 406 forall( dtype DT ) void * ?=?( void * volatile &, DT * ); … … 441 421 forall( dtype DT ) const volatile void * ?=?( const volatile void * &, const volatile DT * ); 442 422 forall( 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 * );462 423 463 424 //forall( dtype DT ) DT * ?=?( DT * &, zero_t ); … … 781 742 forall( dtype DT ) void ?{}( const volatile DT * &, const volatile DT * ); 782 743 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 794 744 forall( dtype DT ) void ?{}( void * &, DT * ); 795 745 forall( dtype DT ) void ?{}( const void * &, DT * ); … … 802 752 forall( dtype DT ) void ?{}( const volatile void * &, const volatile DT * ); 803 753 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 814 754 //forall( dtype DT ) void ?{}( DT * &, zero_t ); 815 755 //forall( dtype DT ) void ?{}( DT * volatile &, zero_t ); -
src/tests/.expect/completeTypeError.txt
rf203a7a r1ba5803 1 completeTypeError.c:3 4:1 error: No reasonable alternatives for expression Applying untyped:1 completeTypeError.c:33:1 error: No reasonable alternatives for expression Applying untyped: 2 2 Name: *? 3 3 ...to: 4 4 Name: v 5 5 6 completeTypeError.c:34:1 error: No reasonable alternatives for expression Applying untyped: 7 Name: *? 8 ...to: 9 Name: y 10 11 completeTypeError.c:35:1 error: No reasonable alternatives for expression Applying untyped: 12 Name: foo 13 ...to: 14 Name: v 6 15 7 16 completeTypeError.c:36:1 error: No reasonable alternatives for expression Applying untyped: … … 10 19 Name: v 11 20 12 13 21 completeTypeError.c:37:1 error: No reasonable alternatives for expression Applying untyped: 14 22 Name: quux 15 23 ...to: 16 24 Name: v 17 18 25 19 26 completeTypeError.c:58:1 error: No reasonable alternatives for expression Applying untyped: … … 22 29 Name: y 23 30 24 25 31 completeTypeError.c:59:1 error: No reasonable alternatives for expression Applying untyped: 26 32 Name: quux 27 33 ...to: 28 34 Name: y 29 30 35 31 36 completeTypeError.c:60:1 error: No reasonable alternatives for expression Applying untyped: … … 34 39 Name: y 35 40 36 37 41 completeTypeError.c:72:1 error: No reasonable alternatives for expression Applying untyped: 38 42 Name: baz … … 40 44 Name: z 41 45 42 -
src/tests/Makefile.am
rf203a7a r1ba5803 141 141 typedefRedef-ERR1: typedefRedef.c @CFA_BINDIR@/@CFA_NAME@ 142 142 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 143 144 alloc-ERROR: alloc.c @CFA_BINDIR@/@CFA_NAME@ 145 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
rf203a7a r1ba5803 895 895 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 896 896 897 alloc-ERROR: alloc.c @CFA_BINDIR@/@CFA_NAME@ 898 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 899 897 900 # Tell versions [3.59,3.63) of GNU make to not export all variables. 898 901 # Otherwise a system limit (for SysV at least) may be exceeded. -
src/tests/alloc.c
rf203a7a r1ba5803 32 32 // allocation, non-array types 33 33 34 p = ( void *)malloc( sizeof(*p) ); // C malloc, type unsafe34 p = (int *)(void *)malloc( sizeof(*p) ); // C malloc, type unsafe 35 35 *p = 0xdeadbeef; 36 36 printf( "C malloc %#x\n", *p ); … … 54 54 printf( "\n" ); 55 55 56 p = calloc( dim, sizeof( *p ) ); // C array calloc, type unsafe56 p = (int *)calloc( dim, sizeof( *p ) ); // C array calloc, type unsafe 57 57 printf( "C array calloc, fill 0\n" ); 58 58 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); } … … 83 83 printf( "\n" ); 84 84 85 p = ( void *)realloc( p, dim * sizeof(*p) ); // C realloc85 p = (int *)(void *)realloc( p, dim * sizeof(*p) ); // C realloc 86 86 for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; } 87 87 printf( "C realloc\n" ); … … 256 256 stp = malloc(); 257 257 printf( "\nSHOULD FAIL\n" ); 258 #ifdef ERR1 258 259 p = alloc( stp, dim * sizeof(*stp) ); 259 260 p = memset( stp, 10 ); 260 261 p = memcpy( &st1, &st ); 262 #endif 261 263 } // main 262 264 -
src/tests/completeTypeError.c
rf203a7a r1ba5803 12 12 void *v; 13 13 14 //A * x;15 //A * y;16 //B * x;17 //B * z;14 A * x; 15 A * y; 16 B * x; 17 B * z; 18 18 19 19 // okay 20 20 *i; 21 //*x; // picks B22 //*z;21 *x; // picks B 22 *z; 23 23 foo(i); 24 24 bar(i); … … 29 29 bar(v); 30 30 qux(v); 31 foo(v); // questionable, but works at the moment for C compatibility32 31 33 32 // bad 34 33 *v; 35 // *y; 34 *y; 35 foo(v); 36 36 baz(v); 37 37 quux(v); -
src/tests/dtor-early-exit.c
rf203a7a r1ba5803 22 22 23 23 struct A { 24 c har * name;24 const char * name; 25 25 int * x; 26 26 }; -
src/tests/init_once.c
rf203a7a r1ba5803 72 72 insert( &constructed, &x ); 73 73 74 x.x = malloc(sizeof(int));74 x.x = (int *)malloc(sizeof(int)); 75 75 } 76 76 -
src/tests/multiDimension.c
rf203a7a r1ba5803 7 7 printf("default constructing\n"); 8 8 (this.a){ 123 }; 9 this.ptr = malloc(sizeof(int));9 this.ptr = (int *)malloc(sizeof(int)); 10 10 } 11 11 … … 13 13 printf("copy constructing\n"); 14 14 (this.a){ other.a }; 15 this.ptr = malloc(sizeof(int));15 this.ptr = (int *)malloc(sizeof(int)); 16 16 } 17 17 … … 19 19 printf("constructing with %d\n", a); 20 20 (this.a){ a }; 21 this.ptr = malloc(sizeof(int));21 this.ptr = (int *)malloc(sizeof(int)); 22 22 } 23 23 -
src/tests/tupleVariadic.c
rf203a7a r1ba5803 73 73 [a0, a1, a2, a3] = args; 74 74 a.size = 4; 75 a.data = malloc(sizeof(int)*a.size);75 a.data = (int *)malloc(sizeof(int)*a.size); 76 76 a.data[0] = a0; 77 77 a.data[1] = a1; -
src/tests/vector/vector_int.c
rf203a7a r1ba5803 27 27 vec.last = -1; 28 28 vec.capacity = reserve; 29 vec.data = malloc( sizeof( int ) * reserve );29 vec.data = (int *)malloc( sizeof( int ) * reserve ); 30 30 } 31 31 … … 33 33 vec.last = other.last; 34 34 vec.capacity = other.capacity; 35 vec.data = malloc( sizeof( int ) * other.capacity );35 vec.data = (int *)malloc( sizeof( int ) * other.capacity ); 36 36 for (int i = 0; i < vec.last; i++) { 37 37 vec.data[i] = other.data[i]; … … 45 45 void reserve( vector_int *vec, int reserve ) { 46 46 if ( reserve > vec->capacity ) { 47 vec->data = realloc( vec->data, sizeof( int ) * reserve );47 vec->data = (int *)realloc( vec->data, sizeof( int ) * reserve ); 48 48 vec->capacity = reserve; 49 49 } … … 54 54 if ( vec->last == vec->capacity ) { 55 55 vec->capacity *= 2; 56 vec->data = realloc( vec->data, sizeof( int ) * vec->capacity );56 vec->data = (int *)realloc( vec->data, sizeof( int ) * vec->capacity ); 57 57 } 58 58 vec->data[ vec->last ] = element;
Note: See TracChangeset
for help on using the changeset viewer.