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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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                }
Note: See TracChangeset for help on using the changeset viewer.