Changes in src/SymTab/Validate.cc [1db21619:145f1fc]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r1db21619 r145f1fc 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T hu Jul 16 16:10:02201513 // Update Count : 18 911 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jul 14 12:27:54 2015 13 // Update Count : 186 14 14 // 15 15 … … 60 60 class HoistStruct : public Visitor { 61 61 public: 62 /// Flattens nested struct types63 62 static void hoistStruct( std::list< Declaration * > &translationUnit ); 64 63 … … 85 84 }; 86 85 87 /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers88 86 class Pass1 : public Visitor { 89 87 typedef Visitor Parent; … … 91 89 virtual void visit( FunctionType *func ); 92 90 }; 93 94 /// Associates forward declarations of aggregates with their definitions 91 95 92 class Pass2 : public Indexer { 96 93 typedef Indexer Parent; … … 113 110 }; 114 111 115 /// Replaces array and function types in forall lists by appropriate pointer type116 112 class Pass3 : public Indexer { 117 113 typedef Indexer Parent; … … 127 123 class AddStructAssignment : public Visitor { 128 124 public: 129 /// Generates assignment operators for aggregate types as required130 125 static void addStructAssignment( std::list< Declaration * > &translationUnit ); 131 126 … … 162 157 class EliminateTypedef : public Mutator { 163 158 public: 164 EliminateTypedef() : scopeLevel( 0 ) {}159 EliminateTypedef() : scopeLevel( 0 ) {} 165 160 static void eliminateTypedef( std::list< Declaration * > &translationUnit ); 166 161 private: … … 168 163 virtual TypeDecl *mutate( TypeDecl *typeDecl ); 169 164 virtual DeclarationWithType *mutate( FunctionDecl *funcDecl ); 170 virtual DeclarationWithType*mutate( ObjectDecl *objDecl );165 virtual ObjectDecl *mutate( ObjectDecl *objDecl ); 171 166 virtual CompoundStmt *mutate( CompoundStmt *compoundStmt ); 172 167 virtual Type *mutate( TypeInstType *aggregateUseType ); … … 449 444 } 450 445 451 /// Fix up assertions452 446 void forallFixer( Type *func ) { 447 // Fix up assertions 453 448 for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) { 454 449 std::list< DeclarationWithType * > toBeDone, nextRound; … … 612 607 613 608 // need to remove the prototypes, since this may be nested in a routine 614 for ( int start = 0, end = assigns.size() / 2; start < end; start++) {609 for (int start = 0, end = assigns.size()/2; start < end; start++) { 615 610 delete assigns.front(); 616 611 assigns.pop_front(); 617 } // for612 } 618 613 619 614 declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() ); … … 822 817 Type *ret = def->second.first->get_base()->clone(); 823 818 ret->get_qualifiers() += typeInst->get_qualifiers(); 824 // place instance parameters on the typedef'd type825 if ( ! typeInst->get_parameters().empty() ) {826 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);827 if ( ! rtt ) {828 throw SemanticError("cannot apply type parameters to base type of " + typeInst->get_name());829 }830 rtt->get_parameters().clear();831 cloneAll(typeInst->get_parameters(), rtt->get_parameters());832 } // if833 819 delete typeInst; 834 820 return ret; … … 884 870 } 885 871 886 DeclarationWithType*EliminateTypedef::mutate( ObjectDecl * objDecl ) {872 ObjectDecl *EliminateTypedef::mutate( ObjectDecl * objDecl ) { 887 873 TypedefMap oldNames = typedefNames; 888 DeclarationWithType *ret = Mutator::mutate( objDecl ); 889 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { 890 return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() ); 891 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) { 892 throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl ); 893 } // if 874 ObjectDecl *ret = Mutator::mutate( objDecl ); 894 875 typedefNames = oldNames; 895 876 return ret; … … 955 936 } 956 937 957 Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {938 Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) { 958 939 Mutator::mutate( contextDecl ); 959 940 return handleAggregate( contextDecl );
Note:
See TracChangeset
for help on using the changeset viewer.