Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    radcdd2f r47534159  
    792792        }
    793793
     794        void AlternativeFinder::visit( AlignofExpr *alignofExpr ) {
     795                if ( alignofExpr->get_isType() ) {
     796                        alternatives.push_back( Alternative( alignofExpr->clone(), env, Cost::zero ) );
     797                } else {
     798                        // find all alternatives for the argument to sizeof
     799                        AlternativeFinder finder( indexer, env );
     800                        finder.find( alignofExpr->get_expr() );
     801                        // find the lowest cost alternative among the alternatives, otherwise ambiguous
     802                        AltList winners;
     803                        findMinCost( finder.alternatives.begin(), finder.alternatives.end(), back_inserter( winners ) );
     804                        if ( winners.size() != 1 ) {
     805                                throw SemanticError( "Ambiguous expression in alignof operand: ", alignofExpr->get_expr() );
     806                        } // if
     807                        // return the lowest cost alternative for the argument
     808                        Alternative &choice = winners.front();
     809                        alternatives.push_back( Alternative( new AlignofExpr( choice.expr->clone() ), choice.env, Cost::zero ) );
     810                } // if
     811        }
     812
    794813        void AlternativeFinder::resolveAttr( DeclarationWithType *funcDecl, FunctionType *function, Type *argType, const TypeEnvironment &env ) {
    795814                // assume no polymorphism
Note: See TracChangeset for help on using the changeset viewer.