Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r5af7306 r98278b3a  
    2020#include <string>                        // for operator==, string
    2121
    22 #include "Common/GC.h"                   // for new_static_root
    2322#include "ResolvExpr/Cost.h"             // for Cost
    2423#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass, TypeEnvironment
     
    276275                        // xxx - not positive this is correct, but appears to allow casting int => enum
    277276                        cost = Cost::unsafe;
    278                 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
    279                         cost = Cost::unsafe;
    280                 } // if
     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.
    281279        }
    282280
     
    310308                                // assignResult == 0 means Cost::Infinity
    311309                        } // if
    312                 } else if ( dynamic_cast< ZeroType * >( dest ) ) {
    313                         cost = Cost::unsafe;
     310                        // case case for zero_t because it should not be possible to convert pointers to zero_t.
    314311                } // if
    315312        }
     
    354351        void ConversionCost::postvisit( EnumInstType * ) {
    355352                static Type::Qualifiers q;
    356                 static BasicType* integer = new_static_root<BasicType>( q, BasicType::SignedInt );
    357                 cost = costFunc( integer, dest, indexer, env );  // safe if dest >= int
     353                static BasicType integer( q, BasicType::SignedInt );
     354                cost = costFunc( &integer, dest, indexer, env );  // safe if dest >= int
    358355                if ( cost < Cost::unsafe ) {
    359356                        cost.incSafe();
Note: See TracChangeset for help on using the changeset viewer.