Changes in / [0dc954b:b1e68d03]
- Location:
- src
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AdjustExprType.cc
r0dc954b rb1e68d03 28 28 void premutate( BasicType * ) { visit_children = false; } 29 29 void premutate( PointerType * ) { visit_children = false; } 30 void premutate( ArrayType * ) { visit_children = false; } 30 31 void premutate( FunctionType * ) { visit_children = false; } 31 32 void premutate( StructInstType * ) { visit_children = false; } … … 59 60 60 61 Type * AdjustExprType::postmutate( ArrayType * arrayType ) { 61 // need to recursively mutate the base type in order for multi-dimensional arrays to work.62 62 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base ); 63 63 arrayType->base = nullptr; -
src/ResolvExpr/AlternativeFinder.cc
r0dc954b rb1e68d03 180 180 throw SemanticError( "No reasonable alternatives for expression ", expr ); 181 181 } 182 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {183 if ( adjust ) {184 adjustExprType( i->expr->get_result(), i->env, indexer );185 }186 }187 182 if ( prune ) { 188 183 PRINT( … … 206 201 std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl; 207 202 ) 203 } 204 // adjust types after pruning so that types substituted by pruneAlternatives are correctly adjusted 205 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) { 206 if ( adjust ) { 207 adjustExprType( i->expr->get_result(), i->env, indexer ); 208 } 208 209 } 209 210 -
src/ResolvExpr/Unify.cc
r0dc954b rb1e68d03 17 17 #include <iterator> // for back_insert_iterator, back_inserter 18 18 #include <map> // for _Rb_tree_const_iterator, _Rb_tree_i... 19 #include <memory> // for unique_ptr , auto_ptr19 #include <memory> // for unique_ptr 20 20 #include <set> // for set 21 21 #include <string> // for string, operator==, operator!=, bas... … … 170 170 Type *common = 0; 171 171 // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to 172 std:: auto_ptr< Type > newType( curClass.type->clone() );172 std::unique_ptr< Type > newType( curClass.type->clone() ); 173 173 newType->get_qualifiers() = typeInst->get_qualifiers(); 174 174 if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) { … … 459 459 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) { 460 460 461 // not positive this is correct in all cases, but it's needed for typedefs462 if ( arrayType->get_isVarLen() || otherArray->get_isVarLen() ) {463 return;464 }465 466 461 if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() && 467 462 arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) { -
src/SymTab/FixFunction.cc
r0dc954b rb1e68d03 50 50 51 51 void FixFunction::premutate(FunctionDecl *) { visit_children = false; } 52 void FixFunction::premutate(ArrayType *) { visit_children = false; } 52 53 void FixFunction::premutate(BasicType *) { visit_children = false; } 53 54 void FixFunction::premutate(PointerType *) { visit_children = false; } -
src/SymTab/FixFunction.h
r0dc954b rb1e68d03 31 31 Type * postmutate(ArrayType * arrayType); 32 32 33 void premutate(ArrayType * arrayType); 33 34 void premutate(VoidType * voidType); 34 35 void premutate(BasicType * basicType); -
src/SymTab/Validate.cc
r0dc954b rb1e68d03 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 { -
src/SynTree/Type.h
r0dc954b rb1e68d03 298 298 void set_isStatic( bool newValue ) { isStatic = newValue; } 299 299 300 virtual bool isComplete() const override { return ! isVarLen; } 300 // array types are complete if they have a dimension expression or are 301 // VLAs ('*' in parameter declaration), and incomplete otherwise. 302 // See 6.7.6.2 303 virtual bool isComplete() const override { return dimension || isVarLen; } 301 304 302 305 virtual ArrayType *clone() const override { return new ArrayType( *this ); } -
src/tests/.expect/castError.txt
r0dc954b rb1e68d03 4 4 ... to: 5 5 charAlternatives are: 6 Cost ( 1, 0, 0, 0 ): Cast of:7 Variable Expression: f: function8 accepting unspecified arguments9 ... returning nothing10 11 ... to:12 char13 (types:14 char15 )16 Environment:17 18 6 Cost ( 1, 0, 0, 0 ): Cast of: 19 7 Variable Expression: f: signed int … … 34 22 Environment: 35 23 24 Cost ( 1, 0, 0, 0 ): Cast of: 25 Variable Expression: f: function 26 accepting unspecified arguments 27 ... returning nothing 36 28 29 ... to: 30 char 31 (types: 32 char 33 ) 34 Environment: 35 36 -
src/tests/Makefile.am
r0dc954b rb1e68d03 138 138 completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@ 139 139 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 140 141 typedefRedef-ERR1: typedefRedef.c @CFA_BINDIR@/@CFA_NAME@ 142 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
r0dc954b rb1e68d03 892 892 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 893 893 894 typedefRedef-ERR1: typedefRedef.c @CFA_BINDIR@/@CFA_NAME@ 895 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 896 894 897 # Tell versions [3.59,3.63) of GNU make to not export all variables. 895 898 # Otherwise a system limit (for SysV at least) may be exceeded.
Note: See TracChangeset
for help on using the changeset viewer.