Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Lvalue.cc

    rd3b7937 rbaba5d8  
    1717
    1818#include "Lvalue.h"
     19
     20#include "GenPoly.h"
    1921
    2022#include "SynTree/Declaration.h"
     
    6365
    6466        namespace {
    65                 bool isLvalueRet( FunctionType *function ) {
    66                         if ( ! function->get_returnVals().empty() ) {
    67                                 return function->get_returnVals().front()->get_type()->get_isLvalue();
    68                         } else {
    69                                 return false;
    70                         } // if
     67                Type* isLvalueRet( FunctionType *function ) {
     68                        if ( function->get_returnVals().empty() ) return 0;
     69                        Type *ty = function->get_returnVals().front()->get_type();
     70                        return ty->get_isLvalue() ? ty : 0;
    7171                }
    7272
     
    107107                        assert( function );
    108108
    109                         std::string typeName;
    110                         if ( isLvalueRet( function ) && ! isIntrinsicApp( appExpr ) ) {
     109                        Type *funType = isLvalueRet( function );
     110                        if ( funType && ! isIntrinsicApp( appExpr ) ) {
     111                                Expression *expr = appExpr;
     112                                Type *appType = appExpr->get_results().front();
     113                                if ( isPolyType( funType ) && ! isPolyType( appType ) ) {
     114                                        // make sure cast for polymorphic type is inside dereference
     115                                        expr = new CastExpr( appExpr, new PointerType( Type::Qualifiers(), appType->clone() ) );
     116                                }
    111117                                UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    112                                 deref->get_results().push_back( appExpr->get_results().front() );
    113                                 appExpr->get_results().front() = new PointerType( Type::Qualifiers(), deref->get_results().front()->clone() );
    114                                 deref->get_args().push_back( appExpr );
     118                                deref->get_results().push_back( appType->clone() );
     119                                appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType );
     120                                deref->get_args().push_back( expr );
    115121                                return deref;
    116122                        } else {
Note: See TracChangeset for help on using the changeset viewer.