Changeset 25b0fde


Ignore:
Timestamp:
Nov 16, 2022, 11:03:51 PM (17 months ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master
Children:
d2ad151
Parents:
db6cdc0
Message:

Fix casted enum init

Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rdb6cdc0 r25b0fde  
    290290                                        if ( obj->get_init() ) {
    291291                                                obj->get_init()->accept( *visitor );
    292                                                 last_val = ((ConstantExpr *)(((SingleInit *)(obj->init))->value))->constant.get_ival();
     292                                                Expression* expr = ((SingleInit *)(obj->init))->value;
     293                                                while ( auto temp = dynamic_cast<CastExpr *>(expr) ) {
     294                                                        expr = temp->arg;
     295                                                }
     296                                                last_val = ((ConstantExpr *)expr)->constant.get_ival();
    293297                                        } else {
    294298                                                output << ++last_val;
Note: See TracChangeset for help on using the changeset viewer.