Changeset 2e9b59b for src/Parser/TypeData.cc
- Timestamp:
- Apr 19, 2022, 3:00:04 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 5b84a321
- Parents:
- ba897d21 (diff), bb7c77d (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
rba897d21 r2e9b59b 918 918 EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 919 919 assert( td->kind == TypeData::Enum ); 920 EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, linkage ); 920 Type * baseType = td->base ? typebuild(td->base) : nullptr; 921 EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, linkage, baseType ); 921 922 buildList( td->enumeration.constants, ret->get_members() ); 922 923 list< Declaration * >::iterator members = ret->get_members().begin(); 923 for ( const DeclarationNode * cur = td->enumeration. 924 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 924 925 if ( cur->has_enumeratorValue() ) { 925 926 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); 926 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 } 927 932 } // if 928 933 } // for 929 ret->set_body( td->enumeration.body ); 934 ret->set_body( td->enumeration.body ); // Boolean; if it has body 930 935 return ret; 931 936 } // buildEnum
Note:
See TracChangeset
for help on using the changeset viewer.