Changeset cad355a
- Timestamp:
- Jul 11, 2016, 5:20:03 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 919d1ba
- Parents:
- 0b4d93ab
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
r0b4d93ab rcad355a 162 162 // but it seems reasonable at the moment for this to be done by makeArrayFunction 163 163 // itself 164 assert( ctor.size() == 1 );165 assert( dtor.size() == 1 );166 objDecl->set_init( new ConstructorInit( new ImplicitCtorDtorStmt( ctor.front() ), new ImplicitCtorDtorStmt( dtor.front()), objDecl->get_init() ) );164 assert( ctor.size() == 1 && dynamic_cast< ImplicitCtorDtorStmt * >( ctor.front() ) ); 165 assert( dtor.size() == 1 && dynamic_cast< ImplicitCtorDtorStmt * >( dtor.front() ) ); 166 objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) ); 167 167 } else { 168 168 // array came with an initializer list: initialize each element -
src/InitTweak/InitTweak.cc
r0b4d93ab rcad355a 66 66 } else if ( CompoundStmt * compoundStmt = dynamic_cast< CompoundStmt * >( stmt ) ) { 67 67 // could also be a compound statement with a loop, in the case of an array 68 assert( compoundStmt->get_kids().size() == 2 ); // loop variable and loop 69 ForStmt * forStmt = dynamic_cast< ForStmt * >( compoundStmt->get_kids().back() ); 70 assert( forStmt && forStmt->get_body() ); 71 return getCtorDtorCall( forStmt->get_body() ); 68 if( compoundStmt->get_kids().size() == 2 ) { 69 // loop variable and loop 70 ForStmt * forStmt = dynamic_cast< ForStmt * >( compoundStmt->get_kids().back() ); 71 assert( forStmt && forStmt->get_body() ); 72 return getCtorDtorCall( forStmt->get_body() ); 73 } else if ( compoundStmt->get_kids().size() == 1 ) { 74 // should be the call statement, but in any case there's only one option 75 return getCtorDtorCall( compoundStmt->get_kids().front() ); 76 } else { 77 assert( false && "too many statements in compoundStmt for getCtorDtorCall" ); 78 } 72 79 } if ( ImplicitCtorDtorStmt * impCtorDtorStmt = dynamic_cast< ImplicitCtorDtorStmt * > ( stmt ) ) { 73 80 return getCtorDtorCall( impCtorDtorStmt->get_callStmt() ); -
src/ResolvExpr/Resolver.cc
r0b4d93ab rcad355a 550 550 // get Variable <array>, then get the base type of the VariableExpr - this is the type that needs to be fixed 551 551 Expression * arr = InitTweak::getCallArg( plusExpr, 0 ); 552 assert( dynamic_cast< VariableExpr * >( arr ) );552 assert( dynamic_cast< VariableExpr * >( arr ) || dynamic_cast< MemberExpr *>( arr ) ); 553 553 assert( arr && arr->get_results().size() == 1 ); 554 554 type = arr->get_results().front()->clone(); … … 559 559 assert( constructee->get_results().size() == 1 ); 560 560 AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee ); 561 assert( addrExpr && addrExpr->get_results().size() == 1 );561 assert( addrExpr && addrExpr->get_results().size() == 1 ); 562 562 type = addrExpr->get_results().front()->clone(); 563 563 } -
src/SymTab/Autogen.cc
r0b4d93ab rcad355a 84 84 } 85 85 86 *out++ = new ExprStmt( noLabels, fExpr ); 86 Statement * callStmt = new ExprStmt( noLabels, fExpr ); 87 if ( (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) ) ) { 88 // implicitly generated ctor/dtor calls should be wrapped 89 // so that later passes are aware they were generated. 90 // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield, 91 // because this causes the address to be taken at codegen, which is illegal in C. 92 callStmt = new ImplicitCtorDtorStmt( callStmt ); 93 } 94 *out++ = callStmt; 87 95 } 88 96 … … 244 252 } 245 253 246 if ( type->get_qualifiers().isConst ) {247 // don't assign const members 254 if ( type->get_qualifiers().isConst && func->get_name() == "?=?" ) { 255 // don't assign const members, but do construct/destruct 248 256 continue; 249 257 } -
src/SymTab/Autogen.h
r0b4d93ab rcad355a 91 91 block->get_kids().push_back( new DeclStmt( noLabels, index ) ); 92 92 block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, new ExprStmt( noLabels, fExpr ) ) ); 93 *out++ = block; 93 94 Statement * stmt = block; 95 if ( fname == "?{}" || fname == "^?{}" ) { 96 // implicitly generated ctor/dtor calls should be wrapped 97 // so that later passes are aware they were generated 98 stmt = new ImplicitCtorDtorStmt( stmt ); 99 } 100 *out++ = stmt; 94 101 } 95 102 } // namespace SymTab -
src/tests/.expect/extension.txt
r0b4d93ab rcad355a 17 17 } 18 18 static inline void ___constructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1){ 19 ((void)((* ___dst__P2sS_1).__a__i_1) /* ?{} */);20 ((void)((* ___dst__P2sS_1).__b__i_1) /* ?{} */);21 ((void)((* ___dst__P2sS_1).__c__i_1) /* ?{} */);19 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ?{} */); 20 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))) /* ?{} */); 21 ((void)((*((int *)(&(*___dst__P2sS_1).__c__i_1)))) /* ?{} */); 22 22 } 23 23 static inline void ___constructor__F_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1){ 24 ((void)((* ___dst__P2sS_1).__a__i_1=___src__2sS_1.__a__i_1) /* ?{} */);25 ((void)((* ___dst__P2sS_1).__b__i_1=___src__2sS_1.__b__i_1) /* ?{} */);26 ((void)((* ___dst__P2sS_1).__c__i_1=___src__2sS_1.__c__i_1) /* ?{} */);24 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))=___src__2sS_1.__a__i_1) /* ?{} */); 25 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))=___src__2sS_1.__b__i_1) /* ?{} */); 26 ((void)((*((int *)(&(*___dst__P2sS_1).__c__i_1)))=___src__2sS_1.__c__i_1) /* ?{} */); 27 27 } 28 28 static inline void ___destructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1){ 29 ((void)((* ___dst__P2sS_1).__c__i_1) /* ^?{} */);30 ((void)((* ___dst__P2sS_1).__b__i_1) /* ^?{} */);31 ((void)((* ___dst__P2sS_1).__a__i_1) /* ^?{} */);29 ((void)((*((int *)(&(*___dst__P2sS_1).__c__i_1)))) /* ^?{} */); 30 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))) /* ^?{} */); 31 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ^?{} */); 32 32 } 33 33 static inline void ___constructor__F_P2sSi_autogen___1(struct S *___dst__P2sS_1, int __a__i_1){ 34 ((void)((* ___dst__P2sS_1).__a__i_1=__a__i_1) /* ?{} */);35 ((void)((* ___dst__P2sS_1).__b__i_1) /* ?{} */);36 ((void)((* ___dst__P2sS_1).__c__i_1) /* ?{} */);34 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))=__a__i_1) /* ?{} */); 35 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))) /* ?{} */); 36 ((void)((*((int *)(&(*___dst__P2sS_1).__c__i_1)))) /* ?{} */); 37 37 } 38 38 static inline void ___constructor__F_P2sSii_autogen___1(struct S *___dst__P2sS_1, int __a__i_1, int __b__i_1){ 39 ((void)((* ___dst__P2sS_1).__a__i_1=__a__i_1) /* ?{} */);40 ((void)((* ___dst__P2sS_1).__b__i_1=__b__i_1) /* ?{} */);41 ((void)((* ___dst__P2sS_1).__c__i_1) /* ?{} */);39 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))=__a__i_1) /* ?{} */); 40 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))=__b__i_1) /* ?{} */); 41 ((void)((*((int *)(&(*___dst__P2sS_1).__c__i_1)))) /* ?{} */); 42 42 } 43 43 static inline void ___constructor__F_P2sSiii_autogen___1(struct S *___dst__P2sS_1, int __a__i_1, int __b__i_1, int __c__i_1){ 44 ((void)((* ___dst__P2sS_1).__a__i_1=__a__i_1) /* ?{} */);45 ((void)((* ___dst__P2sS_1).__b__i_1=__b__i_1) /* ?{} */);46 ((void)((* ___dst__P2sS_1).__c__i_1=__c__i_1) /* ?{} */);44 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))=__a__i_1) /* ?{} */); 45 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))=__b__i_1) /* ?{} */); 46 ((void)((*((int *)(&(*___dst__P2sS_1).__c__i_1)))=__c__i_1) /* ?{} */); 47 47 } 48 48 __extension__ union U {
Note: See TracChangeset
for help on using the changeset viewer.