Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AggregateDecl.cc

    rac3362c r0690350  
    8686std::string TraitDecl::typeString() const { return "trait"; }
    8787
     88namespace {
     89        long long int getConstValue( Expression * expr ) {
     90                if ( CastExpr * castExpr = dynamic_cast< CastExpr * > ( expr ) ) {
     91                        return getConstValue( castExpr->arg );
     92                } else if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) {
     93                        return constExpr->intValue();
     94                // can be -1, +1, etc.
     95                // } else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( expr ) ) {
     96                //      if ( untypedExpr-> )
     97                } else {
     98                        assertf( false, "Unhandled expression type in getConstValue for enumerators: %s", toString( expr ).c_str() );
     99                }
     100        }
     101}
     102
    88103bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) {
    89104        if ( enumValues.empty() ) {
     
    93108                        if ( field->init ) {
    94109                                SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init );
    95                                 auto result = eval( init->value );
    96                                 if ( ! result.second ) SemanticError( init->location, toString( "Non-constexpr in initialization of enumerator: ", field ) );
    97                                 currentValue = result.first;
     110                                currentValue = getConstValue( init->value );
    98111                        }
    99112                        assertf( enumValues.count( field->name ) == 0, "Enum %s has multiple members with the name %s", name.c_str(), field->name.c_str() );
Note: See TracChangeset for help on using the changeset viewer.