Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

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