Changes in src/SymTab/Validate.cc [7e08acf:ac3362c]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r7e08acf rac3362c 62 62 #include "ResolvExpr/typeops.h" // for typesCompatible 63 63 #include "ResolvExpr/Resolver.h" // for findSingleExpression 64 #include "ResolvExpr/ResolveTypeof.h" // for resolveTypeof65 64 #include "SymTab/Autogen.h" // for SizeType 66 65 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 248 247 void previsit( StructInstType * inst ); 249 248 void previsit( UnionInstType * inst ); 250 };251 252 struct FixObjectType : public WithIndexer {253 /// resolves typeof type in object, function, and type declarations254 static void fix( std::list< Declaration * > & translationUnit );255 256 void previsit( ObjectDecl * );257 void previsit( FunctionDecl * );258 void previsit( TypeDecl * );259 249 }; 260 250 … … 322 312 Concurrency::implementThreadStarter( translationUnit ); 323 313 mutateAll( translationUnit, compoundliteral ); 324 ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables325 FixObjectType::fix( translationUnit );326 314 ArrayLength::computeLength( translationUnit ); 327 315 acceptAll( translationUnit, finder ); // xxx - remove this pass soon … … 403 391 assert( aggr ); // TODO: need to handle forward declarations 404 392 for ( Declaration * member : aggr->members ) { 405 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 393 if ( StructInstType * inst = dynamic_cast< StructInstType * >( child ) ) { 394 if ( StructDecl * aggr = dynamic_cast< StructDecl * >( member ) ) { 395 if ( aggr->name == inst->name ) { 396 // TODO: is this case, and other non-TypeInstType cases, necessary? 397 return new StructInstType( qualType->get_qualifiers(), aggr ); 398 } 399 } 400 } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( child ) ) { 401 if ( UnionDecl * aggr = dynamic_cast< UnionDecl * > ( member ) ) { 402 if ( aggr->name == inst->name ) { 403 return new UnionInstType( qualType->get_qualifiers(), aggr ); 404 } 405 } 406 } else if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( child ) ) { 407 if ( EnumDecl * aggr = dynamic_cast< EnumDecl * > ( member ) ) { 408 if ( aggr->name == inst->name ) { 409 return new EnumInstType( qualType->get_qualifiers(), aggr ); 410 } 411 } 412 } else if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 406 413 // name on the right is a typedef 407 414 if ( NamedTypeDecl * aggr = dynamic_cast< NamedTypeDecl * > ( member ) ) { … … 410 417 Type * ret = aggr->base->clone(); 411 418 ret->get_qualifiers() = qualType->get_qualifiers(); 412 TypeSubstitution sub = parent->genericSubstitution();413 sub.apply(ret);414 419 return ret; 415 420 } … … 1233 1238 } 1234 1239 1235 void FixObjectType::fix( std::list< Declaration * > & translationUnit ) {1236 PassVisitor<FixObjectType> fixer;1237 acceptAll( translationUnit, fixer );1238 }1239 1240 void FixObjectType::previsit( ObjectDecl * objDecl ) {1241 Type *new_type = ResolvExpr::resolveTypeof( objDecl->get_type(), indexer );1242 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type1243 objDecl->set_type( new_type );1244 }1245 1246 void FixObjectType::previsit( FunctionDecl * funcDecl ) {1247 Type *new_type = ResolvExpr::resolveTypeof( funcDecl->type, indexer );1248 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type1249 funcDecl->set_type( new_type );1250 }1251 1252 void FixObjectType::previsit( TypeDecl *typeDecl ) {1253 if ( typeDecl->get_base() ) {1254 Type *new_type = ResolvExpr::resolveTypeof( typeDecl->get_base(), indexer );1255 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type1256 typeDecl->set_base( new_type );1257 } // if1258 }1259 1260 1240 void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) { 1261 1241 PassVisitor<ArrayLength> len;
Note:
See TracChangeset
for help on using the changeset viewer.