Changeset b8b075cd


Ignore:
Timestamp:
Dec 18, 2017, 2:27:47 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
fb57626
Parents:
7641b6c
Message:

Apply different costs to conversion of pointers with different types and same qualifiers vs. more qualifiers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r7641b6c rb8b075cd  
    292292                                        cost = Cost::safe;
    293293                                }
    294                         } else {  // xxx - this discards qualifiers from consideration -- reducing qualifiers is a safe conversion; is this right?
     294                        } else {
    295295                                int assignResult = ptrsAssignable( pointerType->base, destAsPtr->base, env );
    296296                                PRINT( std::cerr << " :: " << assignResult << std::endl; )
    297                                 if ( assignResult > 0 && pointerType->get_base()->get_qualifiers() <= destAsPtr->get_qualifiers() ) {
    298                                         cost = Cost::safe;
     297                                if ( assignResult > 0 && tq1 <= tq2 ) {
     298                                        // xxx - want the case where qualifiers are added to be more expensive than the case where qualifiers are the same. Is 1 safe vs. 2 safe correct?
     299                                        if ( tq1 == tq2 ) {
     300                                                cost = Cost::safe;
     301                                        } else if ( tq1 < tq2 ) {
     302                                                cost = Cost::safe+Cost::safe;
     303                                        }
    299304                                } else if ( assignResult < 0 ) {
    300305                                        cost = Cost::unsafe;
Note: See TracChangeset for help on using the changeset viewer.