Changes in / [b1e68d03:0dc954b]


Ignore:
Location:
src
Files:
3 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AdjustExprType.cc

    rb1e68d03 r0dc954b  
    2828                void premutate( BasicType * ) { visit_children = false; }
    2929                void premutate( PointerType * ) { visit_children = false; }
    30                 void premutate( ArrayType * ) { visit_children = false; }
    3130                void premutate( FunctionType * ) { visit_children = false; }
    3231                void premutate( StructInstType * ) { visit_children = false; }
     
    6059
    6160        Type * AdjustExprType::postmutate( ArrayType * arrayType ) {
     61                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
    6262                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base );
    6363                arrayType->base = nullptr;
  • src/ResolvExpr/AlternativeFinder.cc

    rb1e68d03 r0dc954b  
    180180                        throw SemanticError( "No reasonable alternatives for expression ", expr );
    181181                }
     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                }
    182187                if ( prune ) {
    183188                        PRINT(
     
    201206                                std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl;
    202207                        )
    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                         }
    209208                }
    210209
  • src/ResolvExpr/Unify.cc

    rb1e68d03 r0dc954b  
    1717#include <iterator>               // for back_insert_iterator, back_inserter
    1818#include <map>                    // for _Rb_tree_const_iterator, _Rb_tree_i...
    19 #include <memory>                 // for unique_ptr
     19#include <memory>                 // for unique_ptr, auto_ptr
    2020#include <set>                    // for set
    2121#include <string>                 // for string, operator==, operator!=, bas...
     
    170170                                Type *common = 0;
    171171                                // 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() );
    173173                                newType->get_qualifiers() = typeInst->get_qualifiers();
    174174                                if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
     
    459459                if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) {
    460460
     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
    461466                        if ( ! arrayType->get_isVarLen() && ! otherArray->get_isVarLen() &&
    462467                                arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0 ) {
  • src/SymTab/FixFunction.cc

    rb1e68d03 r0dc954b  
    5050
    5151        void FixFunction::premutate(FunctionDecl *) { visit_children = false; }
    52         void FixFunction::premutate(ArrayType *) { visit_children = false; }
    5352        void FixFunction::premutate(BasicType *) { visit_children = false; }
    5453        void FixFunction::premutate(PointerType *) { visit_children = false; }
  • src/SymTab/FixFunction.h

    rb1e68d03 r0dc954b  
    3131                Type * postmutate(ArrayType * arrayType);
    3232
    33                 void premutate(ArrayType * arrayType);
    3433                void premutate(VoidType * voidType);
    3534                void premutate(BasicType * basicType);
  • src/SymTab/Validate.cc

    rb1e68d03 r0dc954b  
    668668                }
    669669                filter( translationUnit, isTypedef, true );
     670
    670671        }
    671672
     
    675676                TypedefMap::const_iterator def = typedefNames.find( typeInst->get_name() );
    676677                if ( def != typedefNames.end() ) {
    677                         Type *ret = def->second.first->base->clone();
     678                        Type *ret = def->second.first->get_base()->clone();
    678679                        ret->get_qualifiers() |= typeInst->get_qualifiers();
    679680                        // place instance parameters on the typedef'd type
    680                         if ( ! typeInst->parameters.empty() ) {
     681                        if ( ! typeInst->get_parameters().empty() ) {
    681682                                ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
    682683                                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());
    684685                                }
    685686                                rtt->get_parameters().clear();
    686                                 cloneAll( typeInst->parameters, rtt->parameters );
    687                                 mutateAll( rtt->parameters, *visitor );  // recursively fix typedefs on parameters
     687                                cloneAll( typeInst->get_parameters(), rtt->get_parameters() );
     688                                mutateAll( rtt->get_parameters(), *visitor );  // recursively fix typedefs on parameters
    688689                        } // if
    689690                        delete typeInst;
     
    691692                } else {
    692693                        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() );
    694695                        typeInst->set_baseType( base->second );
    695696                } // if
    696697                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;
    711698        }
    712699
     
    719706                        Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
    720707                        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() );
    726709                        }
    727710                } else {
  • src/SynTree/Type.h

    rb1e68d03 r0dc954b  
    298298        void set_isStatic( bool newValue ) { isStatic = newValue; }
    299299
    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; }
    304301
    305302        virtual ArrayType *clone() const override { return new ArrayType( *this ); }
  • src/tests/.expect/castError.txt

    rb1e68d03 r0dc954b  
    44... to:
    55  charAlternatives are:
     6Cost ( 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
    618Cost ( 1, 0, 0, 0 ): Cast of:
    719     Variable Expression: f: signed int
     
    2234 Environment:
    2335
    24 Cost ( 1, 0, 0, 0 ): Cast of:
    25      Variable Expression: f: function
    26        accepting unspecified arguments
    27      ... returning nothing
    2836
    29    ... to:
    30      char
    31  (types:
    32    char
    33  )
    34  Environment:
    35 
    36 
  • src/tests/Makefile.am

    rb1e68d03 r0dc954b  
    138138completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@
    139139        ${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  
    892892        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    893893
    894 typedefRedef-ERR1: typedefRedef.c @CFA_BINDIR@/@CFA_NAME@
    895         ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    896 
    897894# Tell versions [3.59,3.63) of GNU make to not export all variables.
    898895# Otherwise a system limit (for SysV at least) may be exceeded.
Note: See TracChangeset for help on using the changeset viewer.