Changes in src/SymTab/Validate.cc [f53836b:bd7e609]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rf53836b rbd7e609 668 668 } 669 669 filter( translationUnit, isTypedef, true ); 670 670 671 } 671 672 … … 675 676 TypedefMap::const_iterator def = typedefNames.find( typeInst->get_name() ); 676 677 if ( def != typedefNames.end() ) { 677 Type *ret = def->second.first-> base->clone();678 Type *ret = def->second.first->get_base()->clone(); 678 679 ret->get_qualifiers() |= typeInst->get_qualifiers(); 679 680 // place instance parameters on the typedef'd type 680 if ( ! typeInst-> parameters.empty() ) {681 if ( ! typeInst->get_parameters().empty() ) { 681 682 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret); 682 683 if ( ! rtt ) { 683 throw SemanticError(" Cannot apply type parameters to base type of " + typeInst->name);684 throw SemanticError("cannot apply type parameters to base type of " + typeInst->get_name()); 684 685 } 685 686 rtt->get_parameters().clear(); 686 cloneAll( typeInst-> parameters, rtt->parameters);687 mutateAll( rtt-> parameters, *visitor ); // recursively fix typedefs on parameters687 cloneAll( typeInst->get_parameters(), rtt->get_parameters() ); 688 mutateAll( rtt->get_parameters(), *visitor ); // recursively fix typedefs on parameters 688 689 } // if 689 690 delete typeInst; … … 691 692 } else { 692 693 TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() ); 693 assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst-> name.c_str() );694 assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->get_name().c_str() ); 694 695 typeInst->set_baseType( base->second ); 695 696 } // if 696 697 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;711 698 } 712 699 … … 719 706 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 720 707 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 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 ); 708 throw SemanticError( "cannot redefine typedef: " + tyDecl->get_name() ); 726 709 } 727 710 } else {
Note:
See TracChangeset
for help on using the changeset viewer.