Changeset 7f6a7c9 for src/Parser/TypeData.cc
- Timestamp:
- Sep 21, 2022, 11:02:15 AM (3 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
r428adbc r7f6a7c9 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:12:51 2015 11 // Last Modified By : Henry Xue12 // Last Modified On : Tue Jul 20 04:10:50 202113 // Update Count : 67 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 10 22:36:52 2022 13 // Update Count : 677 14 14 // 15 15 … … 283 283 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " "; 284 284 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 ] << " "; 293 287 break; 294 288 case Pointer: … … 437 431 __attribute__((fallthrough)); 438 432 #endif 433 // FALL THROUGH 439 434 case Typeof: 440 435 os << "type-of expression "; … … 442 437 typeexpr->print( os, indent + 2 ); 443 438 } // if 439 break; 440 case Vtable: 441 os << "vtable"; 444 442 break; 445 443 case Builtin: … … 548 546 return buildAggInst( td ); 549 547 case TypeData::EnumConstant: 550 // the name gets filled in later -- by SymTab::Validate551 548 return new EnumInstType( buildQualifiers( td ), "" ); 552 549 case TypeData::SymbolicInst: … … 923 920 assert( td->kind == TypeData::Enum ); 924 921 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 ); 926 923 buildList( td->enumeration.constants, ret->get_members() ); 927 924 list< Declaration * >::iterator members = ret->get_members().begin(); 928 925 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() ) { 930 929 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); 931 930 member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) ); 932 931 } else if ( !cur->initializer ) { 933 932 if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isWholeNumber())) { 934 SemanticError( td->location, " A non whole number enum value declmust be explicitly initialized." );933 SemanticError( td->location, "Enumerators of an non-integer typed enum must be explicitly initialized." ); 935 934 } 936 935 }
Note:
See TracChangeset
for help on using the changeset viewer.