Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    ra7c90d4 r23c4aa8  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:51:38 2017
    13 // Update Count     : 179
     12// Last Modified On : Thu Feb 16 14:57:53 2017
     13// Update Count     : 167
    1414//
    1515
     
    120120                void hoist( Type * type );
    121121
    122                 DeclarationNode::StorageClasses storageClasses;
     122                DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;
    123123                bool inFunction = false;
    124124        };
     
    174174
    175175        DeclarationWithType * HoistArrayDimension::mutate( ObjectDecl * objectDecl ) {
    176                 storageClasses = objectDecl->get_storageClasses();
     176                storageclass = objectDecl->get_storageClass();
    177177                DeclarationWithType * temp = Parent::mutate( objectDecl );
    178178                hoist( objectDecl->get_type() );
     179                storageclass = DeclarationNode::NoStorageClass;
    179180                return temp;
    180181        }
     
    184185                static UniqueName dimensionName( "_array_dim" );
    185186
    186                 // C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension.
     187                // C doesn't allow variable sized arrays at global scope or for static variables,
     188                // so don't hoist dimension.
    187189                if ( ! inFunction ) return;
    188                 if ( storageClasses[ DeclarationNode::StaticClass] ) return;
     190                if ( storageclass == DeclarationNode::Static ) return;
    189191
    190192                if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
    191193                        if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist?
    192194
    193                         // don't need to hoist dimension if it's a constexpr - only need to if there's potential for side effects.
     195                        // don't need to hoist dimension if it's a constexpr - only need to if there's potential
     196                        // for side effects.
    194197                        if ( isConstExpr( arrayType->get_dimension() ) ) return;
    195198
    196                         ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );
     199                        ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageclass, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );
    197200                        arrayDimension->get_type()->set_isConst( true );
    198201
Note: See TracChangeset for help on using the changeset viewer.