Ignore:
Timestamp:
Sep 21, 2022, 11:02:15 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
95dab9e
Parents:
428adbc (diff), 0bd46fd (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:

Merge branch 'master' into pthread-emulation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cc

    r428adbc r7f6a7c9  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Henry Xue
    12 // Last Modified On : Tue Jul 20 04:10:50 2021
    13 // Update Count     : 673
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 10 22:36:52 2022
     13// Update Count     : 677
    1414//
    1515
     
    283283                if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " ";
    284284                if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " ";
    285                 if ( complextype == DeclarationNode::NoComplexType ) { // basic type
    286                         assert( basictype != DeclarationNode::NoBasicType );
    287                         os << DeclarationNode::basicTypeNames[ basictype ] << " ";
    288                 } else {                                                                                // complex type
    289                         // handle double _Complex
    290                         if ( basictype != DeclarationNode::NoBasicType ) os << DeclarationNode::basicTypeNames[ basictype ] << " ";
    291                         os << DeclarationNode::complexTypeNames[ complextype ] << " ";
    292                 } // if
     285                if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeNames[ complextype ] << " ";
     286                if ( basictype != DeclarationNode::NoBasicType ) os << DeclarationNode::basicTypeNames[ basictype ] << " ";
    293287                break;
    294288          case Pointer:
     
    437431                        __attribute__((fallthrough));
    438432                #endif
     433                // FALL THROUGH
    439434          case Typeof:
    440435                os << "type-of expression ";
     
    442437                        typeexpr->print( os, indent + 2 );
    443438                } // if
     439                break;
     440          case Vtable:
     441                os << "vtable";
    444442                break;
    445443          case Builtin:
     
    548546                return buildAggInst( td );
    549547          case TypeData::EnumConstant:
    550                 // the name gets filled in later -- by SymTab::Validate
    551548                return new EnumInstType( buildQualifiers( td ), "" );
    552549          case TypeData::SymbolicInst:
     
    923920        assert( td->kind == TypeData::Enum );
    924921        Type * baseType = td->base ? typebuild(td->base) : nullptr;
    925         EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, linkage, baseType );
     922        EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, td->enumeration.typed, linkage, baseType );
    926923        buildList( td->enumeration.constants, ret->get_members() );
    927924        list< Declaration * >::iterator members = ret->get_members().begin();
    928925        for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
    929                 if ( cur->has_enumeratorValue() ) {
     926                if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) {
     927                        SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." );
     928                } else if ( cur->has_enumeratorValue() ) {
    930929                        ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
    931930                        member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) );
    932931                } else if ( !cur->initializer ) {
    933932                        if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isWholeNumber())) {
    934                                 SemanticError( td->location, "A non whole number enum value decl must be explicitly initialized." );
     933                                SemanticError( td->location, "Enumerators of an non-integer typed enum must be explicitly initialized." );
    935934                        }
    936935                }
Note: See TracChangeset for help on using the changeset viewer.