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