Changes in src/Parser/DeclarationNode.cc [be00a2d:0d0931d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rbe00a2d r0d0931d 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 12:34:05 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Feb 25 12:15:40 202313 // Update Count : 140 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Mar 14 11:56:00 2023 13 // Update Count : 1406 14 14 // 15 15 … … 41 41 42 42 // These must harmonize with the corresponding DeclarationNode enumerations. 43 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "int128", 44 "float", "double", "long double", "float80", "float128", 45 "_float16", "_float32", "_float32x", "_float64", "_float64x", "_float128", "_float128x", "NoBasicTypeNames" }; 46 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "NoComplexTypeNames", "_Imaginary" }; // Imaginary unsupported => parse, but make invisible and print error message 47 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 48 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; 49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; 43 const char * DeclarationNode::basicTypeNames[] = { 44 "void", "_Bool", "char", "int", "int128", 45 "float", "double", "long double", "float80", "float128", 46 "_float16", "_float32", "_float32x", "_float64", "_float64x", "_float128", "_float128x", "NoBasicTypeNames" 47 }; 48 const char * DeclarationNode::complexTypeNames[] = { 49 "_Complex", "NoComplexTypeNames", "_Imaginary" 50 }; // Imaginary unsupported => parse, but make invisible and print error message 51 const char * DeclarationNode::signednessNames[] = { 52 "signed", "unsigned", "NoSignednessNames" 53 }; 54 const char * DeclarationNode::lengthNames[] = { 55 "short", "long", "long long", "NoLengthNames" 56 }; 57 const char * DeclarationNode::builtinTypeNames[] = { 58 "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" 59 }; 50 60 51 61 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 70 80 delete variable.initializer; 71 81 72 // 82 // delete type; 73 83 delete bitfieldWidth; 74 84 … … 504 514 // src is the new item being added and has a single bit 505 515 } else if ( ! src->storageClasses.is_threadlocal_any() ) { // conflict ? 506 appendError( error, string( "conflicting " ) + Type::StorageClassesNames[storageClasses.ffs()] + 507 " & " + Type::StorageClassesNames[src->storageClasses.ffs()] ); 516 appendError( error, string( "conflicting " ) 517 + Type::StorageClassesNames[storageClasses.ffs()] 518 + " & " + Type::StorageClassesNames[src->storageClasses.ffs()] ); 508 519 src->storageClasses.reset(); // FIX to preserve invariant of one basic storage specifier 509 520 } // if … … 589 600 } else { 590 601 switch ( dst->kind ) { 591 602 case TypeData::Unknown: 592 603 src->qualifiers |= dst->qualifiers; 593 604 dst = src; 594 605 src = nullptr; 595 606 break; 596 607 case TypeData::Basic: 597 608 dst->qualifiers |= src->qualifiers; 598 609 if ( src->kind != TypeData::Unknown ) { … … 622 633 } // if 623 634 break; 624 635 default: 625 636 switch ( src->kind ) { 626 627 637 case TypeData::Aggregate: 638 case TypeData::Enum: 628 639 dst->base = new TypeData( TypeData::AggregateInst ); 629 640 dst->base->aggInst.aggregate = src; … … 634 645 src = nullptr; 635 646 break; 636 647 default: 637 648 if ( dst->forall ) { 638 649 dst->forall->appendList( src->forall ); … … 706 717 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 707 718 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { 708 709 710 711 712 713 719 if ( variable.assertions ) { 720 variable.assertions->appendList( assertions ); 721 } else { 722 variable.assertions = assertions; 723 } // if 724 return this; 714 725 } // if 715 726 716 727 assert( type ); 717 728 switch ( type->kind ) { 718 729 case TypeData::Symbolic: 719 730 if ( type->symbolic.assertions ) { 720 731 type->symbolic.assertions->appendList( assertions ); … … 723 734 } // if 724 735 break; 725 736 default: 726 737 assert( false ); 727 738 } // switch … … 822 833 if ( type ) { 823 834 switch ( type->kind ) { 824 825 835 case TypeData::Aggregate: 836 case TypeData::Enum: 826 837 p->type->base = new TypeData( TypeData::AggregateInst ); 827 838 p->type->base->aggInst.aggregate = type; … … 832 843 break; 833 844 834 845 default: 835 846 p->type->base = type; 836 847 } // switch … … 854 865 855 866 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) { 856 867 if ( ! a ) return this; 857 868 assert( a->type->kind == TypeData::Array ); 858 869 TypeData * lastArray = findLast( a->type ); 859 870 if ( type ) { 860 871 switch ( type->kind ) { 861 862 872 case TypeData::Aggregate: 873 case TypeData::Enum: 863 874 lastArray->base = new TypeData( TypeData::AggregateInst ); 864 875 lastArray->base->aggInst.aggregate = type; … … 868 879 lastArray->base->qualifiers |= type->qualifiers; 869 880 break; 870 881 default: 871 882 lastArray->base = type; 872 883 } // switch … … 1204 1215 } // if 1205 1216 bool isDelete = initializer && initializer->get_isDelete(); 1206 Declaration * decl = buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild < Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, isDelete ? nullptr : maybeBuild< Initializer >(initializer), attributes )->set_extension( extension );1217 Declaration * decl = buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild( bitfieldWidth ), funcSpecs, linkage, asmName, isDelete ? nullptr : maybeBuild(initializer), attributes )->set_extension( extension ); 1207 1218 if ( isDelete ) { 1208 1219 DeclarationWithType * dwt = strict_dynamic_cast<DeclarationWithType *>( decl ); … … 1213 1224 1214 1225 if ( assert.condition ) { 1215 return new StaticAssertDecl( maybeBuild < Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) );1226 return new StaticAssertDecl( maybeBuild( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) ); 1216 1227 } 1217 1228 … … 1227 1238 } // if 1228 1239 assertf( name, "ObjectDecl must a have name\n" ); 1229 return (new ObjectDecl( *name, storageClasses, linkage, maybeBuild < Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_asmName( asmName )->set_extension( extension );1240 return (new ObjectDecl( *name, storageClasses, linkage, maybeBuild( bitfieldWidth ), nullptr, maybeBuild( initializer ) ))->set_asmName( asmName )->set_extension( extension ); 1230 1241 } 1231 1242 … … 1234 1245 1235 1246 switch ( type->kind ) { 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1247 case TypeData::Enum: 1248 case TypeData::Aggregate: { 1249 ReferenceToType * ret = buildComAggInst( type, attributes, linkage ); 1250 buildList( type->aggregate.actuals, ret->get_parameters() ); 1251 return ret; 1252 } 1253 case TypeData::Symbolic: { 1254 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false, attributes ); 1255 buildList( type->symbolic.actuals, ret->get_parameters() ); 1256 return ret; 1257 } 1258 default: 1248 1259 Type * simpletypes = typebuild( type ); 1249 1260 simpletypes->get_attributes() = attributes; // copy because member is const
Note: See TracChangeset
for help on using the changeset viewer.