Changeset 66f8528 for src/ResolvExpr


Ignore:
Timestamp:
Dec 15, 2016, 5:16:42 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
43385ca, f7ff3fb
Parents:
5802a4f (diff), 596f987b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into tuples

Conflicts:

src/ResolvExpr/CommonType.cc
src/tests/.expect/32/extension.txt
src/tests/.expect/32/gccExtensions.txt
src/tests/.expect/64/declarationSpecifier.txt
src/tests/.expect/64/extension.txt
src/tests/.expect/64/gccExtensions.txt
src/tests/.expect/castError.txt
src/tests/Makefile.am

Location:
src/ResolvExpr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/ResolvExpr/CommonType.cc

    r5802a4f r66f8528  
    4242                virtual void visit( OneType *oneType );
    4343
     44                void getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer );
    4445                template< typename RefType > void handleRefType( RefType *inst, Type *other );
    4546
     
    143144        }
    144145
    145         /// true if a common type for t must be a complete type
    146         bool requiredComplete( Type * t ) {
    147                 if ( TypeInstType * inst = dynamic_cast< TypeInstType * > ( t ) ) {
    148                         return inst->get_baseType()->isComplete();
     146        void CommonType::getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer ) {
     147                if ( TypeInstType* var = dynamic_cast< TypeInstType* >( otherPointer->get_base() ) ) {
     148                        OpenVarSet::const_iterator entry = openVars.find( var->get_name() );
     149                        if ( entry != openVars.end() ) {
     150                                AssertionSet need, have;
     151                                WidenMode widen( widenFirst, widenSecond );
     152                                if ( entry != openVars.end() && ! bindVar(var, voidPointer->get_base(), entry->second, env, need, have, openVars, widen, indexer ) ) return;
     153                        }
    149154                }
    150                 return false;
     155                result = voidPointer->clone();
     156                result->get_qualifiers() += otherPointer->get_qualifiers();
    151157        }
    152158
    153159        void CommonType::visit( PointerType *pointerType ) {
    154160                if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) {
    155                         // Note: relationship between formal and actual types is antisymmetric
    156                         //   void free(void *);
    157                         //   forall(otype T) void foo(T *);
    158                         //
    159                         // should be able to pass T* to free, but should not be able to pass a void* to foo.
    160                         // because of this, the requiredComplete check occurs only on the first, since it corresponds
    161                         // to the formal parameter type (though this may be incorrect in some cases, in which case
    162                         // perhaps the widen mode needs to incorporate another bit for whether this is a formal or actual context)
    163                         if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) && ! requiredComplete( pointerType->get_base() ) ) {
    164                                 result = otherPointer->clone();
    165                                 result->get_qualifiers() += pointerType->get_qualifiers();
     161                        if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) ) {
     162                                getCommonWithVoidPointer( otherPointer, pointerType );
    166163                        } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base(), indexer) ) {
    167                                 result = pointerType->clone();
    168                                 result->get_qualifiers() += otherPointer->get_qualifiers();
     164                                getCommonWithVoidPointer( pointerType, otherPointer );
    169165                        } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst )
    170166                                           && ( pointerType->get_base()->get_qualifiers() <= otherPointer->get_base()->get_qualifiers() || widenSecond ) ) {
     
    256252                                        result->get_qualifiers() += zeroType->get_qualifiers();
    257253                                }
     254                        } else if ( widenSecond && dynamic_cast< OneType* >( type2 ) ) {
     255                                result = new BasicType( zeroType->get_qualifiers(), BasicType::SignedInt );
     256                                result->get_qualifiers() += type2->get_qualifiers();
    258257                        }
    259258                }
     
    267266                                        result->get_qualifiers() += oneType->get_qualifiers();
    268267                                }
     268                        } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) {
     269                                result = new BasicType( oneType->get_qualifiers(), BasicType::SignedInt );
     270                                result->get_qualifiers() += type2->get_qualifiers();
    269271                        }
    270272                }
  • TabularUnified src/ResolvExpr/Resolver.cc

    r5802a4f r66f8528  
    404404        template< typename AggrInst >
    405405        TypeSubstitution makeGenericSubstitutuion( AggrInst * inst ) {
     406                assert( inst );
     407                assert( inst->get_baseParameters() );
    406408                std::list< TypeDecl * > baseParams = *inst->get_baseParameters();
    407409                std::list< Expression * > typeSubs = inst->get_parameters();
     
    444446
    445447        void Resolver::resolveAggrInit( ReferenceToType * inst, InitIterator & init, InitIterator & initEnd ) {
    446 
    447448                if ( StructInstType * sit = dynamic_cast< StructInstType * >( inst ) ) {
    448449                        TypeSubstitution sub = makeGenericSubstitutuion( sit );
     
    455456                        }
    456457                } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) {
    457                         TypeSubstitution sub = makeGenericSubstitutuion( sit );
     458                        TypeSubstitution sub = makeGenericSubstitutuion( uit );
    458459                        UnionDecl * un = uit->get_baseUnion();
    459460                        // only resolve to the first member of a union
  • TabularUnified src/ResolvExpr/Unify.cc

    r5802a4f r66f8528  
    3131
    3232namespace ResolvExpr {
    33         struct WidenMode {
    34                 WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}
    35                 WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }
    36                 WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }
    37                 WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }
    38                 WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
    39                 operator bool() { return widenFirst && widenSecond; }
    40 
    41                 bool widenFirst : 1, widenSecond : 1;
    42         };
    4333
    4434        class Unify : public Visitor {
  • TabularUnified src/ResolvExpr/Unify.h

    r5802a4f r66f8528  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Unify.h -- 
     7// Unify.h --
    88//
    99// Author           : Richard C. Bilson
     
    2727
    2828namespace ResolvExpr {
     29        struct WidenMode {
     30                WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}
     31                WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }
     32                WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }
     33                WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }
     34                WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
     35                operator bool() { return widenFirst && widenSecond; }
     36
     37                bool widenFirst : 1, widenSecond : 1;
     38        };
     39
     40        bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
    2941        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
    3042        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
Note: See TracChangeset for help on using the changeset viewer.