Changes in src/InitTweak/FixInit.cc [0a81c3f:62423350]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r0a81c3f r62423350 364 364 assert( ftype ); 365 365 if ( isConstructor( funcDecl->get_name() ) && ftype->get_parameters().size() == 2 ) { 366 Type * t1 = getPointerBase( ftype->get_parameters().front()->get_type());366 Type * t1 = ftype->get_parameters().front()->get_type(); 367 367 Type * t2 = ftype->get_parameters().back()->get_type(); 368 assert( t1 );369 370 if ( ResolvExpr::typesCompatible( t1, t2, SymTab::Indexer() ) ) {368 PointerType * ptrType = safe_dynamic_cast< PointerType * > ( t1 ); 369 370 if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) { 371 371 // optimization: don't need to copy construct in order to call a copy constructor 372 372 return appExpr; … … 401 401 402 402 bool ResolveCopyCtors::skipCopyConstruct( Type * type ) { 403 return dynamic_cast< VarArgsType * >( type ) || dynamic_cast< ReferenceType * >( type ) ||GenPoly::getFunctionType( type ) || Tuples::isTtype( type );403 return dynamic_cast< VarArgsType * >( type ) || GenPoly::getFunctionType( type ) || Tuples::isTtype( type ); 404 404 } 405 405 … … 489 489 impCpCtorExpr->get_returnDecls().push_back( ret ); 490 490 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; ) 491 if ( ! dynamic_cast< ReferenceType * >( result) ) {491 if ( ! result->get_lvalue() ) { 492 492 // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary 493 493 destructRet( ret, impCpCtorExpr ); … … 997 997 assert( ! type->get_parameters().empty() ); 998 998 thisParam = safe_dynamic_cast< ObjectDecl * >( type->get_parameters().front() ); 999 Type * thisType = getPointerBase( thisParam->get_type() );1000 StructInstType * structType = dynamic_cast< StructInstType * >( thisType);999 PointerType * ptrType = safe_dynamic_cast< PointerType * > ( thisParam->get_type() ); 1000 StructInstType * structType = dynamic_cast< StructInstType * >( ptrType->get_base() ); 1001 1001 if ( structType ) { 1002 1002 structDecl = structType->get_baseStruct(); … … 1046 1046 // insert and resolve default/copy constructor call for each field that's unhandled 1047 1047 std::list< Statement * > stmt; 1048 UntypedExpr * deref = UntypedExpr::createDeref( new VariableExpr( thisParam ) ); 1049 1048 1050 Expression * arg2 = 0; 1049 1051 if ( isCopyConstructor( function ) ) { … … 1054 1056 } 1055 1057 InitExpander srcParam( arg2 ); 1056 SymTab::genImplicitCall( srcParam, new MemberExpr( field, new VariableExpr( thisParam )), function->get_name(), back_inserter( stmt ), field, isCtor );1058 SymTab::genImplicitCall( srcParam, new MemberExpr( field, deref ), function->get_name(), back_inserter( stmt ), field, isCtor ); 1057 1059 1058 1060 assert( stmt.size() <= 1 );
Note:
See TracChangeset
for help on using the changeset viewer.