Changeset f238fcc2 for src/Parser/TypeData.cc
- Timestamp:
- Mar 21, 2022, 3:17:37 PM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 4390fb6
- Parents:
- 3e54399
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
r3e54399 rf238fcc2 918 918 EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 919 919 assert( td->kind == TypeData::Enum ); 920 Type * baseType = td->base ? typebuild(td->base) : nullptr;920 Type * baseType = td->base ? typebuild(td->base) : nullptr; 921 921 EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, linkage, baseType ); 922 buildList( td->enumeration.constants, ret->get_members() ); // enumConstant is both a node and a list922 buildList( td->enumeration.constants, ret->get_members() ); 923 923 list< Declaration * >::iterator members = ret->get_members().begin(); 924 924 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { … … 926 926 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); 927 927 member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) ); 928 } else { 929 if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isWholeNumber())) { 930 SemanticError( td->location, "A non whole number enum value decl must be explicitly initialized." ); 931 } 928 932 } // if 929 933 } // for
Note: See TracChangeset
for help on using the changeset viewer.