Changeset ac3362c
- Timestamp:
- Aug 3, 2018, 11:56:53 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- f271bdd
- Parents:
- 3537dd7
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r3537dd7 rac3362c 738 738 forwardEnums.erase( fwds ); 739 739 } // if 740 741 for ( Declaration * member : enumDecl->members ) { 742 ObjectDecl * field = strict_dynamic_cast<ObjectDecl *>( member ); 743 if ( field->init ) { 744 // need to resolve enumerator initializers early so that other passes that determine if an expression is constexpr have the appropriate information. 745 SingleInit * init = strict_dynamic_cast<SingleInit *>( field->init ); 746 ResolvExpr::findSingleExpression( init->value, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), indexer ); 747 } 748 } 740 749 } // if 741 750 } -
src/SynTree/AggregateDecl.cc
r3537dd7 rac3362c 86 86 std::string TraitDecl::typeString() const { return "trait"; } 87 87 88 namespace {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 103 88 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { 104 89 if ( enumValues.empty() ) { … … 108 93 if ( field->init ) { 109 94 SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init ); 110 currentValue = getConstValue( init->value ); 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; 111 98 } 112 99 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.