Changes in src/InitTweak/GenInit.cc [23c4aa8:a7c90d4]
- File:
-
- 1 edited
-
src/InitTweak/GenInit.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
r23c4aa8 ra7c90d4 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 16 14:57:53201713 // Update Count : 1 6712 // Last Modified On : Tue Mar 7 07:51:38 2017 13 // Update Count : 179 14 14 // 15 15 … … 120 120 void hoist( Type * type ); 121 121 122 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;122 DeclarationNode::StorageClasses storageClasses; 123 123 bool inFunction = false; 124 124 }; … … 174 174 175 175 DeclarationWithType * HoistArrayDimension::mutate( ObjectDecl * objectDecl ) { 176 storage class = objectDecl->get_storageClass();176 storageClasses = objectDecl->get_storageClasses(); 177 177 DeclarationWithType * temp = Parent::mutate( objectDecl ); 178 178 hoist( objectDecl->get_type() ); 179 storageclass = DeclarationNode::NoStorageClass;180 179 return temp; 181 180 } … … 185 184 static UniqueName dimensionName( "_array_dim" ); 186 185 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. 189 187 if ( ! inFunction ) return; 190 if ( storage class == DeclarationNode::Static) return;188 if ( storageClasses[ DeclarationNode::StaticClass] ) return; 191 189 192 190 if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) { 193 191 if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist? 194 192 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. 197 194 if ( isConstExpr( arrayType->get_dimension() ) ) return; 198 195 199 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storage class, 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() ) ); 200 197 arrayDimension->get_type()->set_isConst( true ); 201 198
Note:
See TracChangeset
for help on using the changeset viewer.