Changes in src/SymTab/Validate.cc [8a3ecb9:fd2debf]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r8a3ecb9 rfd2debf 61 61 #include "Parser/LinkageSpec.h" // for C 62 62 #include "ResolvExpr/typeops.h" // for typesCompatible 63 #include "ResolvExpr/Resolver.h" // for findSingleExpression 63 64 #include "SymTab/Autogen.h" // for SizeType 64 65 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 72 73 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 73 74 #include "SynTree/Visitor.h" // for Visitor 75 #include "Validate/HandleAttributes.h" // for handleAttributes 74 76 75 77 class CompoundStmt; … … 85 87 void previsit( AlignofExpr * ); 86 88 void previsit( UntypedOffsetofExpr * ); 89 void previsit( CompoundLiteralExpr * ); 87 90 void handleType( Type * ); 88 91 }; … … 246 249 }; 247 250 248 struct ArrayLength {251 struct ArrayLength : public WithIndexer { 249 252 /// for array types without an explicit length, compute the length and store it so that it 250 253 /// is known to the rest of the phases. For example, … … 257 260 258 261 void previsit( ObjectDecl * objDecl ); 262 void previsit( ArrayType * arrayType ); 259 263 }; 260 264 … … 311 315 acceptAll( translationUnit, finder ); // xxx - remove this pass soon 312 316 mutateAll( translationUnit, labelAddrFixer ); 317 Validate::handleAttributes( translationUnit ); 313 318 } 314 319 … … 348 353 void HoistTypeDecls::previsit( UntypedOffsetofExpr * expr ) { 349 354 handleType( expr->type ); 355 } 356 357 void HoistTypeDecls::previsit( CompoundLiteralExpr * expr ) { 358 handleType( expr->result ); 350 359 } 351 360 … … 1227 1236 void ArrayLength::previsit( ObjectDecl * objDecl ) { 1228 1237 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1229 if ( at-> get_dimension()) return;1238 if ( at->dimension ) return; 1230 1239 if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->init ) ) { 1231 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) ); 1232 } 1240 at->dimension = new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ); 1241 } 1242 } 1243 } 1244 1245 void ArrayLength::previsit( ArrayType * type ) { 1246 if ( type->dimension ) { 1247 // need to resolve array dimensions early so that constructor code can correctly determine 1248 // if a type is a VLA (and hence whether its elements need to be constructed) 1249 ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer ); 1250 1251 // must re-evaluate whether a type is a VLA, now that more information is available 1252 // (e.g. the dimension may have been an enumerator, which was unknown prior to this step) 1253 type->isVarLen = ! InitTweak::isConstExpr( type->dimension ); 1233 1254 } 1234 1255 }
Note: See TracChangeset
for help on using the changeset viewer.