Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r0a81c3f r62423350  
    364364                                        assert( ftype );
    365365                                        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();
    367367                                                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() ) ) {
    371371                                                        // optimization: don't need to copy construct in order to call a copy constructor
    372372                                                        return appExpr;
     
    401401
    402402                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 );
    404404                }
    405405
     
    489489                                impCpCtorExpr->get_returnDecls().push_back( ret );
    490490                                CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
    491                                 if ( ! dynamic_cast< ReferenceType * >( result ) ) {
     491                                if ( ! result->get_lvalue() ) {
    492492                                        // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary
    493493                                        destructRet( ret, impCpCtorExpr );
     
    997997                                assert( ! type->get_parameters().empty() );
    998998                                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() );
    10011001                                if ( structType ) {
    10021002                                        structDecl = structType->get_baseStruct();
     
    10461046                                        // insert and resolve default/copy constructor call for each field that's unhandled
    10471047                                        std::list< Statement * > stmt;
     1048                                        UntypedExpr * deref = UntypedExpr::createDeref( new VariableExpr( thisParam ) );
     1049
    10481050                                        Expression * arg2 = 0;
    10491051                                        if ( isCopyConstructor( function ) ) {
     
    10541056                                        }
    10551057                                        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 );
    10571059
    10581060                                        assert( stmt.size() <= 1 );
Note: See TracChangeset for help on using the changeset viewer.