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