Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r98278b3a r5af7306  
    2020#include <string>                        // for operator==, string
    2121
     22#include "Common/GC.h"                   // for new_static_root
    2223#include "ResolvExpr/Cost.h"             // for Cost
    2324#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass, TypeEnvironment
     
    275276                        // xxx - not positive this is correct, but appears to allow casting int => enum
    276277                        cost = Cost::unsafe;
    277                 } // if
    278                 // no cases for zero_t/one_t because it should not be possible to convert int, etc. to zero_t/one_t.
     278                } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
     279                        cost = Cost::unsafe;
     280                } // if
    279281        }
    280282
     
    308310                                // assignResult == 0 means Cost::Infinity
    309311                        } // if
    310                         // case case for zero_t because it should not be possible to convert pointers to zero_t.
     312                } else if ( dynamic_cast< ZeroType * >( dest ) ) {
     313                        cost = Cost::unsafe;
    311314                } // if
    312315        }
     
    351354        void ConversionCost::postvisit( EnumInstType * ) {
    352355                static Type::Qualifiers q;
    353                 static BasicType integer( q, BasicType::SignedInt );
    354                 cost = costFunc( &integer, dest, indexer, env );  // safe if dest >= int
     356                static BasicType* integer = new_static_root<BasicType>( q, BasicType::SignedInt );
     357                cost = costFunc( integer, dest, indexer, env );  // safe if dest >= int
    355358                if ( cost < Cost::unsafe ) {
    356359                        cost.incSafe();
Note: See TracChangeset for help on using the changeset viewer.