Changeset 5668740 for src/AST/Decl.cpp


Ignore:
Timestamp:
Jun 14, 2023, 11:35:49 AM (13 months ago)
Author:
caparsons <caparson@…>
Branches:
master
Children:
7e4bd9b6
Parents:
32a4f3e (diff), 8f557161 (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:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r32a4f3e r5668740  
    142142bool EnumDecl::valueOf( const Decl * enumerator, long long& value ) const {
    143143        if ( enumValues.empty() ) {
    144                 long long crntVal = 0;
     144                Evaluation crntVal = {0, true, true};  // until expression is given, we know to start counting from 0
    145145                for ( const Decl * member : members ) {
    146146                        const ObjectDecl* field = strict_dynamic_cast< const ObjectDecl* >( member );
    147147                        if ( field->init ) {
    148148                                const SingleInit * init = strict_dynamic_cast< const SingleInit* >( field->init.get() );
    149                                 auto result = eval( init->value );
    150                                 if ( ! result.second ) {
     149                                crntVal = eval( init->value );
     150                                if ( ! crntVal.isEvaluableInGCC ) {
    151151                                        SemanticError( init->location, ::toString( "Non-constexpr in initialization of "
    152152                                                "enumerator: ", field ) );
    153153                                }
    154                                 crntVal = result.first;
    155154                        }
    156155                        if ( enumValues.count( field->name ) != 0 ) {
    157156                                SemanticError( location, ::toString( "Enum ", name, " has multiple members with the "   "name ", field->name ) );
    158157                        }
    159                         enumValues[ field->name ] = crntVal;
    160                         ++crntVal;
     158                        if (crntVal.hasKnownValue) {
     159                                enumValues[ field->name ] = crntVal.knownValue;
     160                        }
     161                        ++crntVal.knownValue;
    161162                }
    162163        }
Note: See TracChangeset for help on using the changeset viewer.