Changeset 3a5131ed for src/Parser/TypeData.cc
- Timestamp:
- Feb 16, 2017, 3:36:45 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 317450e
- Parents:
- c3d9adc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
rc3d9adc r3a5131ed 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 27 15:28:56201713 // Update Count : 4 2812 // Last Modified On : Thu Feb 16 15:06:59 2017 13 // Update Count : 455 14 14 // 15 15 … … 724 724 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 725 725 if ( td->kind == TypeData::Function ) { 726 if ( td->function.idList ) { 727 buildKRFunction( td->function ); 728 } // if 729 726 730 FunctionDecl * decl; 727 731 if ( td->function.hasBody ) { … … 738 742 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), nullptr, isInline, isNoreturn, attributes ); 739 743 } // if 740 for ( DeclarationNode * cur = td->function.idList; cur != nullptr; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {741 if ( cur->name ) {742 decl->get_oldIdents().insert( decl->get_oldIdents().end(), *cur->name );743 } // if744 } // for745 buildList( td->function.oldDeclList, decl->get_oldDecls() );746 744 return decl->set_asmName( asmName ); 747 745 } else if ( td->kind == TypeData::Aggregate ) { … … 778 776 } // buildFunction 779 777 778 void buildKRFunction( const TypeData::Function_t & function ) { 779 assert( ! function.params ); 780 for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = dynamic_cast< DeclarationNode* >( decl->get_next() ) ) { 781 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) { 782 if ( *decl->name == *param->name ) { 783 if ( param->type ) throw SemanticError( string( "duplicate declaration name " ) + *param->name ); 784 if ( ! decl->type ) throw SemanticError( string( "duplicate parameter name " ) + *param->name ); 785 param->type = decl->type; 786 decl->type = nullptr; 787 param->attributes.splice( param->attributes.end(), decl->attributes ); 788 } // if 789 } // for 790 if ( decl->type ) throw SemanticError( string( "missing name in parameter list " ) + *decl->name ); 791 } // for 792 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) { 793 if ( ! param->type ) { 794 param->type = new TypeData( TypeData::Basic ); 795 param->type->basictype = DeclarationNode::Int; 796 } // if 797 } // for 798 799 function.params = function.idList; 800 function.idList = nullptr; 801 delete function.oldDeclList; 802 function.oldDeclList = nullptr; 803 } // buildKRFunction 804 780 805 // Local Variables: // 781 806 // tab-width: 4 //
Note: See TracChangeset
for help on using the changeset viewer.