Changeset e6491ca
- Timestamp:
- Jan 20, 2025, 10:59:43 PM (12 days ago)
- Branches:
- master
- Children:
- 5dad25df
- Parents:
- df56e25
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cpp
rdf56e25 re6491ca 162 162 // FROM USER: float a[ rand() ]; 163 163 // TO GCC: const size_t __len_of_a = rand(); float a[ __len_of_a ]; 164 165 ast::ObjectDecl * arrayDimension = new ast::ObjectDecl( 166 arrayType->dimension->location, 167 dimensionName.newName(), 168 dimType, 169 new ast::SingleInit( 164 ast::ObjectDecl * arrayDimension = nullptr; 165 166 const ast::TypeExpr * ty = dynamic_cast< const ast::TypeExpr * >( arrayType->dimension.get() ); 167 if ( ty ) { 168 auto inst = ty->type.as<ast::EnumInstType>(); 169 if ( inst ) { 170 if ( inst->base->isCfa ) { 171 arrayDimension = new ast::ObjectDecl( 172 arrayType->dimension->location, 173 dimensionName.newName(), 174 new ast::BasicType( ast::BasicKind::UnsignedChar ), 175 new ast::SingleInit( 176 arrayType->dimension->location, 177 ast::ConstantExpr::from_int( arrayType->dimension->location, inst->base->members.size() ) 178 ) 179 ); 180 // return arrayType; 181 } 182 } 183 } 184 if ( arrayDimension == nullptr ) { 185 arrayDimension = new ast::ObjectDecl( 170 186 arrayType->dimension->location, 171 arrayType->dimension 172 ) 173 ); 187 dimensionName.newName(), 188 dimType, 189 new ast::SingleInit( 190 arrayType->dimension->location, 191 arrayType->dimension 192 ) 193 ); 194 } 174 195 175 196 ast::ArrayType * mutType = ast::mutate( arrayType );
Note: See TracChangeset
for help on using the changeset viewer.