- Timestamp:
- Jun 13, 2023, 4:33:16 PM (12 months ago)
- Branches:
- master
- Children:
- 5668740, fec8bd1
- Parents:
- 576aadb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.cpp
r576aadb r8f557161 142 142 bool EnumDecl::valueOf( const Decl * enumerator, long long& value ) const { 143 143 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 145 145 for ( const Decl * member : members ) { 146 146 const ObjectDecl* field = strict_dynamic_cast< const ObjectDecl* >( member ); 147 147 if ( field->init ) { 148 148 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 ) { 151 151 SemanticError( init->location, ::toString( "Non-constexpr in initialization of " 152 152 "enumerator: ", field ) ); 153 153 } 154 crntVal = result.first;155 154 } 156 155 if ( enumValues.count( field->name ) != 0 ) { 157 156 SemanticError( location, ::toString( "Enum ", name, " has multiple members with the " "name ", field->name ) ); 158 157 } 159 enumValues[ field->name ] = crntVal; 160 ++crntVal; 158 if (crntVal.hasKnownValue) { 159 enumValues[ field->name ] = crntVal.knownValue; 160 } 161 ++crntVal.knownValue; 161 162 } 162 163 }
Note: See TracChangeset
for help on using the changeset viewer.