Changeset f53836b
- Timestamp:
- Oct 23, 2017, 5:41:50 PM (7 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:
- 0e04f59
- Parents:
- 954ef5b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r954ef5b rf53836b 668 668 } 669 669 filter( translationUnit, isTypedef, true ); 670 671 670 } 672 671 … … 676 675 TypedefMap::const_iterator def = typedefNames.find( typeInst->get_name() ); 677 676 if ( def != typedefNames.end() ) { 678 Type *ret = def->second.first-> get_base()->clone();677 Type *ret = def->second.first->base->clone(); 679 678 ret->get_qualifiers() |= typeInst->get_qualifiers(); 680 679 // place instance parameters on the typedef'd type 681 if ( ! typeInst-> get_parameters().empty() ) {680 if ( ! typeInst->parameters.empty() ) { 682 681 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret); 683 682 if ( ! rtt ) { 684 throw SemanticError(" cannot apply type parameters to base type of " + typeInst->get_name());683 throw SemanticError("Cannot apply type parameters to base type of " + typeInst->name); 685 684 } 686 685 rtt->get_parameters().clear(); 687 cloneAll( typeInst-> get_parameters(), rtt->get_parameters());688 mutateAll( rtt-> get_parameters(), *visitor ); // recursively fix typedefs on parameters686 cloneAll( typeInst->parameters, rtt->parameters ); 687 mutateAll( rtt->parameters, *visitor ); // recursively fix typedefs on parameters 689 688 } // if 690 689 delete typeInst; … … 692 691 } else { 693 692 TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() ); 694 assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst-> get_name().c_str() );693 assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->name.c_str() ); 695 694 typeInst->set_baseType( base->second ); 696 695 } // if 697 696 return typeInst; 697 } 698 699 struct VarLenChecker : WithShortCircuiting { 700 void previsit( FunctionType * ) { visit_children = false; } 701 void previsit( ArrayType * at ) { 702 isVarLen |= at->isVarLen; 703 } 704 bool isVarLen = false; 705 }; 706 707 bool isVariableLength( Type * t ) { 708 PassVisitor<VarLenChecker> varLenChecker; 709 maybeAccept( t, varLenChecker ); 710 return varLenChecker.pass.isVarLen; 698 711 } 699 712 … … 706 719 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 707 720 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 708 throw SemanticError( "cannot redefine typedef: " + tyDecl->get_name() ); 721 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name ); 722 } 723 // cannot redefine VLA typedefs 724 if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) { 725 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name ); 709 726 } 710 727 } else {
Note: See TracChangeset
for help on using the changeset viewer.