Changeset f238fcc2 for src/ResolvExpr


Ignore:
Timestamp:
Mar 21, 2022, 3:17:37 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
4390fb6
Parents:
3e54399
Message:

Enable numeric type for typed enum

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r3e54399 rf238fcc2  
    333333                } else if ( dynamic_cast< const EnumInstType * >( dest ) ) {
    334334                        // xxx - not positive this is correct, but appears to allow casting int => enum
    335                         cost = Cost::unsafe;
     335                        // TODO
     336                        EnumDecl * decl = dynamic_cast< const EnumInstType * >( dest )->baseEnum;
     337                        if ( decl->base ) {
     338                                cost = Cost::infinity;
     339                        } else {
     340                                cost = Cost::unsafe;
     341                        } // if
    336342                } // if
    337343                // no cases for zero_t/one_t because it should not be possible to convert int, etc. to zero_t/one_t.
     
    610616        } else if ( dynamic_cast< const ast::EnumInstType * >( dst ) ) {
    611617                // xxx - not positive this is correct, but appears to allow casting int => enum
    612                 cost = Cost::unsafe;
     618                const ast::EnumDecl * decl = (dynamic_cast< const ast::EnumInstType * >( dst ))->base.get();
     619                if ( decl->base ) {
     620                        cost = Cost::infinity;
     621                } else {
     622                        cost = Cost::unsafe;
     623                } // if
    613624        }
    614625}
Note: See TracChangeset for help on using the changeset viewer.