Changes in src/SymTab/Validate.cc [ac3362c:8a3ecb9]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rac3362c r8a3ecb9 61 61 #include "Parser/LinkageSpec.h" // for C 62 62 #include "ResolvExpr/typeops.h" // for typesCompatible 63 #include "ResolvExpr/Resolver.h" // for findSingleExpression64 63 #include "SymTab/Autogen.h" // for SizeType 65 64 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 73 72 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 74 73 #include "SynTree/Visitor.h" // for Visitor 75 #include "Validate/HandleAttributes.h" // for handleAttributes76 74 77 75 class CompoundStmt; … … 87 85 void previsit( AlignofExpr * ); 88 86 void previsit( UntypedOffsetofExpr * ); 89 void previsit( CompoundLiteralExpr * );90 87 void handleType( Type * ); 91 88 }; … … 249 246 }; 250 247 251 struct ArrayLength : public WithIndexer{248 struct ArrayLength { 252 249 /// for array types without an explicit length, compute the length and store it so that it 253 250 /// is known to the rest of the phases. For example, … … 260 257 261 258 void previsit( ObjectDecl * objDecl ); 262 void previsit( ArrayType * arrayType );263 259 }; 264 260 … … 315 311 acceptAll( translationUnit, finder ); // xxx - remove this pass soon 316 312 mutateAll( translationUnit, labelAddrFixer ); 317 Validate::handleAttributes( translationUnit );318 313 } 319 314 … … 353 348 void HoistTypeDecls::previsit( UntypedOffsetofExpr * expr ) { 354 349 handleType( expr->type ); 355 }356 357 void HoistTypeDecls::previsit( CompoundLiteralExpr * expr ) {358 handleType( expr->result );359 350 } 360 351 … … 738 729 forwardEnums.erase( fwds ); 739 730 } // if 740 741 for ( Declaration * member : enumDecl->members ) {742 ObjectDecl * field = strict_dynamic_cast<ObjectDecl *>( member );743 if ( field->init ) {744 // need to resolve enumerator initializers early so that other passes that determine if an expression is constexpr have the appropriate information.745 SingleInit * init = strict_dynamic_cast<SingleInit *>( field->init );746 ResolvExpr::findSingleExpression( init->value, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), indexer );747 }748 }749 731 } // if 750 732 } … … 1245 1227 void ArrayLength::previsit( ObjectDecl * objDecl ) { 1246 1228 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1247 if ( at-> dimension) return;1229 if ( at->get_dimension() ) return; 1248 1230 if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->init ) ) { 1249 at->dimension = new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ); 1250 } 1251 } 1252 } 1253 1254 void ArrayLength::previsit( ArrayType * type ) { 1255 if ( type->dimension ) { 1256 // need to resolve array dimensions early so that constructor code can correctly determine 1257 // if a type is a VLA (and hence whether its elements need to be constructed) 1258 ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer ); 1259 1260 // must re-evaluate whether a type is a VLA, now that more information is available 1261 // (e.g. the dimension may have been an enumerator, which was unknown prior to this step) 1262 type->isVarLen = ! InitTweak::isConstExpr( type->dimension ); 1231 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) ); 1232 } 1263 1233 } 1264 1234 }
Note:
See TracChangeset
for help on using the changeset viewer.