Ignore:
Timestamp:
May 13, 2024, 7:07:06 AM (17 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
ca4f2b2
Parents:
ec20ab9 (diff), 5f225f5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

fix merge

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CastCost.cpp

    rec20ab9 rbf4fe05  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CastCost.cc --
     7// CastCost.cpp --
    88//
    99// Author           : Richard C. Bilson
     
    2222#include "AST/Type.hpp"
    2323#include "AST/TypeEnvironment.hpp"
    24 #include "ConversionCost.h            // for ConversionCost
    25 #include "Cost.h                      // for Cost, Cost::infinity
    26 #include "ResolvExpr/ConversionCost.h // for conversionCost
     24#include "ConversionCost.hpp"            // for ConversionCost
     25#include "Cost.hpp"                      // for Cost, Cost::infinity
     26#include "ResolvExpr/ConversionCost.hpp" // for conversionCost
    2727#include "ResolvExpr/PtrsCastable.hpp"   // for ptrsCastable
    28 #include "ResolvExpr/Unify.h          // for typesCompatibleIgnoreQualifiers
     28#include "ResolvExpr/Unify.hpp"          // for typesCompatibleIgnoreQualifiers
    2929
    3030#if 0
     
    5454                                cost = conversionCost( basicType, dst, srcIsLvalue, symtab, env );
    5555                                if ( Cost::unsafe < cost ) {
    56                                         if (auto enumInst =  dynamic_cast<const ast::EnumInstType *>(dst)) {
    57                                                 assert(enumInst->base->base);
    58                                                 cost = Cost::unsafe;
     56                                        if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) {
     57                                                // Always explict cast only for typed enum
     58                                                if (enumInst->base->isTyped) cost = Cost::unsafe;
    5959                                        }
    6060                                }
     
    6363
    6464                void postvisit( const ast::ZeroType * zero ) {
    65                         // auto ptr = dynamic_cast< const ast::PointerType * >( dst );
    66                         // if ( ptr && basicType->isInteger() ) {
    67                         //      // needed for, e.g. unsigned long => void *
    68                         //      cost = Cost::unsafe;
    69                         // } else {
    7065                        cost = conversionCost( zero, dst, srcIsLvalue, symtab, env );
    7166                        if ( Cost::unsafe < cost ) {
    7267                                if (auto enumInst =  dynamic_cast<const ast::EnumInstType *>(dst)) {
    73                                         assert(enumInst->base->base);
    74                                         cost = Cost::unsafe;
     68                                        if (enumInst->base->isTyped) cost = Cost::unsafe;
    7569                                }
    7670                        }
    77                         // }
    7871                }
    7972
    8073                void postvisit( const ast::OneType * one ) {
    81                         // auto ptr = dynamic_cast< const ast::PointerType * >( dst );
    82                         // if ( ptr && basicType->isInteger() ) {
    83                         //      // needed for, e.g. unsigned long => void *
    84                         //      cost = Cost::unsafe;
    85                         // } else {
    8674                        cost = conversionCost( one, dst, srcIsLvalue, symtab, env );
    8775                        if ( Cost::unsafe < cost ) {
    88                                 if (auto enumInst =  dynamic_cast<const ast::EnumInstType *>(dst)) {
    89                                         assert(enumInst->base->base);
    90                                         cost = Cost::unsafe;
     76                                if (auto enumInst = dynamic_cast<const ast::EnumInstType *>(dst)) {
     77                                        if (enumInst->base->isTyped) cost = Cost::unsafe;
    9178                                }
    9279                        }
    93                         // }
    9480                }
    9581
Note: See TracChangeset for help on using the changeset viewer.