Changes in src/SymTab/Validate.cc [73737e5:51b986f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r73737e5 r51b986f 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Jul 13 14:38:19201513 // Update Count : 1 8412 // Last Modified On : Wed Jul 22 13:16:00 2015 13 // Update Count : 194 14 14 // 15 15 … … 162 162 class EliminateTypedef : public Mutator { 163 163 public: 164 EliminateTypedef() : scopeLevel( 0 ) {} 165 /// Replaces typedefs by forward declarations 164 EliminateTypedef() : scopeLevel( 0 ) {} 166 165 static void eliminateTypedef( std::list< Declaration * > &translationUnit ); 167 166 private: … … 169 168 virtual TypeDecl *mutate( TypeDecl *typeDecl ); 170 169 virtual DeclarationWithType *mutate( FunctionDecl *funcDecl ); 171 virtual ObjectDecl*mutate( ObjectDecl *objDecl );170 virtual DeclarationWithType *mutate( ObjectDecl *objDecl ); 172 171 virtual CompoundStmt *mutate( CompoundStmt *compoundStmt ); 173 172 virtual Type *mutate( TypeInstType *aggregateUseType ); … … 203 202 void validateType( Type *type, const Indexer *indexer ) { 204 203 Pass1 pass1; 204 Pass2 pass2( false, indexer ); 205 205 Pass3 pass3( indexer ); 206 206 type->accept( pass1 ); 207 type->accept( pass2 ); 207 208 type->accept( pass3 ); 208 209 } … … 403 404 } // for 404 405 } // for 406 407 if ( ctx->get_parameters().size() != contextInst->get_parameters().size() ) { 408 throw SemanticError( "incorrect number of context parameters: ", contextInst ); 409 } // if 410 405 411 applySubstitution( ctx->get_parameters().begin(), ctx->get_parameters().end(), contextInst->get_parameters().begin(), ctx->get_members().begin(), ctx->get_members().end(), back_inserter( contextInst->get_members() ) ); 406 412 } … … 534 540 init->get_args().push_back( new NameExpr( "0" ) ); 535 541 Statement *initStmt = new ExprStmt( noLabels, init ); 536 542 std::list<Statement *> initList; 543 initList.push_back( initStmt ); 544 537 545 UntypedExpr *cond = new UntypedExpr( new NameExpr( "?<?" ) ); 538 546 cond->get_args().push_back( new VariableExpr( index ) ); … … 559 567 assignExpr->get_args().push_back( srcIndex ); 560 568 561 *out++ = new ForStmt( noLabels, init Stmt, cond, inc, new ExprStmt( noLabels, assignExpr ) );569 *out++ = new ForStmt( noLabels, initList, cond, inc, new ExprStmt( noLabels, assignExpr ) ); 562 570 } 563 571 … … 609 617 610 618 // need to remove the prototypes, since this may be nested in a routine 611 for ( int start = 0, end = assigns.size()/2; start < end; start++) {619 for ( int start = 0, end = assigns.size() / 2; start < end; start++ ) { 612 620 delete assigns.front(); 613 621 assigns.pop_front(); 614 } 622 } // for 615 623 616 624 declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() ); … … 827 835 rtt->get_parameters().clear(); 828 836 cloneAll(typeInst->get_parameters(), rtt->get_parameters()); 829 } 837 } // if 830 838 delete typeInst; 831 839 return ret; … … 881 889 } 882 890 883 ObjectDecl*EliminateTypedef::mutate( ObjectDecl * objDecl ) {891 DeclarationWithType *EliminateTypedef::mutate( ObjectDecl * objDecl ) { 884 892 TypedefMap oldNames = typedefNames; 885 ObjectDecl *ret = Mutator::mutate( objDecl ); 893 DeclarationWithType *ret = Mutator::mutate( objDecl ); 894 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { 895 return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() ); 896 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) { 897 throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl ); 898 } // if 886 899 typedefNames = oldNames; 887 900 return ret; … … 947 960 } 948 961 949 962 Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) { 950 963 Mutator::mutate( contextDecl ); 951 964 return handleAggregate( contextDecl );
Note:
See TracChangeset
for help on using the changeset viewer.