Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rbe00a2d r0d0931d  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 12:34:05 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 25 12:15:40 2023
    13 // Update Count     : 1404
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Mar 14 11:56:00 2023
     13// Update Count     : 1406
    1414//
    1515
     
    4141
    4242// 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" };
     43const 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};
     48const char * DeclarationNode::complexTypeNames[] = {
     49        "_Complex", "NoComplexTypeNames", "_Imaginary"
     50}; // Imaginary unsupported => parse, but make invisible and print error message
     51const char * DeclarationNode::signednessNames[] = {
     52        "signed", "unsigned", "NoSignednessNames"
     53};
     54const char * DeclarationNode::lengthNames[] = {
     55        "short", "long", "long long", "NoLengthNames"
     56};
     57const char * DeclarationNode::builtinTypeNames[] = {
     58        "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames"
     59};
    5060
    5161UniqueName DeclarationNode::anonymous( "__anonymous" );
     
    7080        delete variable.initializer;
    7181
    72 //      delete type;
     82//      delete type;
    7383        delete bitfieldWidth;
    7484
     
    504514                        // src is the new item being added and has a single bit
    505515                } 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()] );
    508519                        src->storageClasses.reset();                            // FIX to preserve invariant of one basic storage specifier
    509520                } // if
     
    589600        } else {
    590601                switch ( dst->kind ) {
    591                   case TypeData::Unknown:
     602                case TypeData::Unknown:
    592603                        src->qualifiers |= dst->qualifiers;
    593604                        dst = src;
    594605                        src = nullptr;
    595606                        break;
    596                   case TypeData::Basic:
     607                case TypeData::Basic:
    597608                        dst->qualifiers |= src->qualifiers;
    598609                        if ( src->kind != TypeData::Unknown ) {
     
    622633                        } // if
    623634                        break;
    624                   default:
     635                default:
    625636                        switch ( src->kind ) {
    626                           case TypeData::Aggregate:
    627                           case TypeData::Enum:
     637                        case TypeData::Aggregate:
     638                        case TypeData::Enum:
    628639                                dst->base = new TypeData( TypeData::AggregateInst );
    629640                                dst->base->aggInst.aggregate = src;
     
    634645                                src = nullptr;
    635646                                break;
    636                           default:
     647                        default:
    637648                                if ( dst->forall ) {
    638649                                        dst->forall->appendList( src->forall );
     
    706717DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) {
    707718        if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) {
    708                 if ( variable.assertions ) {
    709                         variable.assertions->appendList( assertions );
    710                 } else {
    711                         variable.assertions = assertions;
    712                 } // if
    713                 return this;
     719                if ( variable.assertions ) {
     720                        variable.assertions->appendList( assertions );
     721                } else {
     722                        variable.assertions = assertions;
     723                } // if
     724                return this;
    714725        } // if
    715726
    716727        assert( type );
    717728        switch ( type->kind ) {
    718           case TypeData::Symbolic:
     729        case TypeData::Symbolic:
    719730                if ( type->symbolic.assertions ) {
    720731                        type->symbolic.assertions->appendList( assertions );
     
    723734                } // if
    724735                break;
    725           default:
     736        default:
    726737                assert( false );
    727738        } // switch
     
    822833                if ( type ) {
    823834                        switch ( type->kind ) {
    824                           case TypeData::Aggregate:
    825                           case TypeData::Enum:
     835                        case TypeData::Aggregate:
     836                        case TypeData::Enum:
    826837                                p->type->base = new TypeData( TypeData::AggregateInst );
    827838                                p->type->base->aggInst.aggregate = type;
     
    832843                                break;
    833844
    834                           default:
     845                        default:
    835846                                p->type->base = type;
    836847                        } // switch
     
    854865
    855866DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) {
    856   if ( ! a ) return this;
     867        if ( ! a ) return this;
    857868        assert( a->type->kind == TypeData::Array );
    858869        TypeData * lastArray = findLast( a->type );
    859870        if ( type ) {
    860871                switch ( type->kind ) {
    861                   case TypeData::Aggregate:
    862                   case TypeData::Enum:
     872                case TypeData::Aggregate:
     873                case TypeData::Enum:
    863874                        lastArray->base = new TypeData( TypeData::AggregateInst );
    864875                        lastArray->base->aggInst.aggregate = type;
     
    868879                        lastArray->base->qualifiers |= type->qualifiers;
    869880                        break;
    870                   default:
     881                default:
    871882                        lastArray->base = type;
    872883                } // switch
     
    12041215                } // if
    12051216                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 );
    12071218                if ( isDelete ) {
    12081219                        DeclarationWithType * dwt = strict_dynamic_cast<DeclarationWithType *>( decl );
     
    12131224
    12141225        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 ) ) );
    12161227        }
    12171228
     
    12271238        } // if
    12281239        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 );
    12301241}
    12311242
     
    12341245
    12351246        switch ( type->kind ) {
    1236           case TypeData::Enum:
    1237           case TypeData::Aggregate: {
    1238                   ReferenceToType * ret = buildComAggInst( type, attributes, linkage );
    1239                   buildList( type->aggregate.actuals, ret->get_parameters() );
    1240                   return ret;
    1241           }
    1242           case TypeData::Symbolic: {
    1243                   TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false, attributes );
    1244                   buildList( type->symbolic.actuals, ret->get_parameters() );
    1245                   return ret;
    1246           }
    1247           default:
     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:
    12481259                Type * simpletypes = typebuild( type );
    12491260                simpletypes->get_attributes() = attributes;             // copy because member is const
Note: See TracChangeset for help on using the changeset viewer.