Ignore:
Timestamp:
Apr 19, 2022, 3:00:04 PM (3 years ago)
Author:
m3zulfiq <m3zulfiq@…>
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.
Message:

added benchmark and evaluations chapter to thesis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cc

    rba897d21 r2e9b59b  
    918918EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    919919        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 );
    921922        buildList( td->enumeration.constants, ret->get_members() );
    922923        list< Declaration * >::iterator members = ret->get_members().begin();
    923         for ( const DeclarationNode * cur = td->enumeration. constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
     924        for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
    924925                if ( cur->has_enumeratorValue() ) {
    925926                        ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
    926927                        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                        }
    927932                } // if
    928933        } // for
    929         ret->set_body( td->enumeration.body );
     934        ret->set_body( td->enumeration.body ); // Boolean; if it has body
    930935        return ret;
    931936} // buildEnum
Note: See TracChangeset for help on using the changeset viewer.