Changeset 1571e4d


Ignore:
Timestamp:
Aug 3, 2024, 11:36:26 PM (4 hours ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
06ecda9
Parents:
4e107bf
Message:

reinterpret loop start for enum type as the first enumerator

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.hfa

    r4e107bf r1571e4d  
    6666                return l;
    6767        }
     68
     69        E ?+=? ( E & l, one_t ) {
     70                l = succ(l);
     71                return l;
     72        }
    6873       
    6974        E ?++( E & l ) {
  • src/ResolvExpr/ResolveTypeof.cpp

    r4e107bf r1571e4d  
    130130        mutDecl->type = renameTyVars(mutDecl->type, RenameMode::GEN_EXPR_ID);
    131131        mutDecl->isTypeFixed = true;
     132
     133        auto enumInst = decl->type.as<ast::EnumInstType>();
     134        if ( enumInst && enumInst->base->isCfa ) {
     135                if ( auto init = decl->init.as<ast::SingleInit>() ) {
     136                        if ( auto initExpr = init->value.as<ast::ConstantExpr>() ) {
     137                                if ( initExpr->result.as<ast::ZeroType>() ) {
     138                                        auto newInit = new ast::SingleInit( init->location,
     139                                                ast::UntypedExpr::createCall( init->location, "lowerBound", {} )
     140                                        );
     141                                        mutDecl->init = newInit;
     142                                }
     143                        }
     144                }
     145        }
     146
    132147        return mutDecl;
    133148}
Note: See TracChangeset for help on using the changeset viewer.