Changes in / [b1e68d03:0dc954b]
- Location:
- src
- Files:
-
- 3 deleted
- 10 edited
-
ResolvExpr/AdjustExprType.cc (modified) (2 diffs)
-
ResolvExpr/AlternativeFinder.cc (modified) (2 diffs)
-
ResolvExpr/Unify.cc (modified) (3 diffs)
-
SymTab/FixFunction.cc (modified) (1 diff)
-
SymTab/FixFunction.h (modified) (1 diff)
-
SymTab/Validate.cc (modified) (4 diffs)
-
SynTree/Type.h (modified) (1 diff)
-
tests/.expect/castError.txt (modified) (2 diffs)
-
tests/.expect/typedefRedef-ERR1.txt (deleted)
-
tests/.expect/typedefRedef.txt (deleted)
-
tests/Makefile.am (modified) (1 diff)
-
tests/Makefile.in (modified) (1 diff)
-
tests/typedefRedef.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AdjustExprType.cc
rb1e68d03 r0dc954b 28 28 void premutate( BasicType * ) { visit_children = false; } 29 29 void premutate( PointerType * ) { visit_children = false; } 30 void premutate( ArrayType * ) { visit_children = false; }31 30 void premutate( FunctionType * ) { visit_children = false; } 32 31 void premutate( StructInstType * ) { visit_children = false; } … … 60 59 61 60 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
rb1e68d03 r0dc954b 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 } 182 187 if ( prune ) { 183 188 PRINT( … … 201 206 std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl; 202 207 ) 203 }204 // adjust types after pruning so that types substituted by pruneAlternatives are correctly adjusted205 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {206 if ( adjust ) {207 adjustExprType( i->expr->get_result(), i->env, indexer );208 }209 208 } 210 209 -
src/ResolvExpr/Unify.cc
rb1e68d03 r0dc954b 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 19 #include <memory> // for unique_ptr, auto_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:: unique_ptr< Type > newType( curClass.type->clone() );172 std::auto_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 typedefs 462 if ( arrayType->get_isVarLen() || otherArray->get_isVarLen() ) { 463 return; 464 } 465 461 466 if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() && 462 467 arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) { -
src/SymTab/FixFunction.cc
rb1e68d03 r0dc954b 50 50 51 51 void FixFunction::premutate(FunctionDecl *) { visit_children = false; } 52 void FixFunction::premutate(ArrayType *) { visit_children = false; }53 52 void FixFunction::premutate(BasicType *) { visit_children = false; } 54 53 void FixFunction::premutate(PointerType *) { visit_children = false; } -
src/SymTab/FixFunction.h
rb1e68d03 r0dc954b 31 31 Type * postmutate(ArrayType * arrayType); 32 32 33 void premutate(ArrayType * arrayType);34 33 void premutate(VoidType * voidType); 35 34 void premutate(BasicType * basicType); -
src/SymTab/Validate.cc
rb1e68d03 r0dc954b 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 { -
src/SynTree/Type.h
rb1e68d03 r0dc954b 298 298 void set_isStatic( bool newValue ) { isStatic = newValue; } 299 299 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; } 300 virtual bool isComplete() const override { return ! isVarLen; } 304 301 305 302 virtual ArrayType *clone() const override { return new ArrayType( *this ); } -
src/tests/.expect/castError.txt
rb1e68d03 r0dc954b 4 4 ... to: 5 5 charAlternatives are: 6 Cost ( 1, 0, 0, 0 ): Cast of: 7 Variable Expression: f: function 8 accepting unspecified arguments 9 ... returning nothing 10 11 ... to: 12 char 13 (types: 14 char 15 ) 16 Environment: 17 6 18 Cost ( 1, 0, 0, 0 ): Cast of: 7 19 Variable Expression: f: signed int … … 22 34 Environment: 23 35 24 Cost ( 1, 0, 0, 0 ): Cast of:25 Variable Expression: f: function26 accepting unspecified arguments27 ... returning nothing28 36 29 ... to:30 char31 (types:32 char33 )34 Environment:35 36 -
src/tests/Makefile.am
rb1e68d03 r0dc954b 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
rb1e68d03 r0dc954b 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 897 894 # Tell versions [3.59,3.63) of GNU make to not export all variables. 898 895 # Otherwise a system limit (for SysV at least) may be exceeded.
Note:
See TracChangeset
for help on using the changeset viewer.