Changeset 66f8528 for src/ResolvExpr/CommonType.cc
- Timestamp:
- Dec 15, 2016, 5:16:42 PM (8 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CommonType.cc
r5802a4f r66f8528 42 42 virtual void visit( OneType *oneType ); 43 43 44 void getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer ); 44 45 template< typename RefType > void handleRefType( RefType *inst, Type *other ); 45 46 … … 143 144 } 144 145 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 } 149 154 } 150 return false; 155 result = voidPointer->clone(); 156 result->get_qualifiers() += otherPointer->get_qualifiers(); 151 157 } 152 158 153 159 void CommonType::visit( PointerType *pointerType ) { 154 160 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 ); 166 163 } 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 ); 169 165 } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst ) 170 166 && ( pointerType->get_base()->get_qualifiers() <= otherPointer->get_base()->get_qualifiers() || widenSecond ) ) { … … 256 252 result->get_qualifiers() += zeroType->get_qualifiers(); 257 253 } 254 } else if ( widenSecond && dynamic_cast< OneType* >( type2 ) ) { 255 result = new BasicType( zeroType->get_qualifiers(), BasicType::SignedInt ); 256 result->get_qualifiers() += type2->get_qualifiers(); 258 257 } 259 258 } … … 267 266 result->get_qualifiers() += oneType->get_qualifiers(); 268 267 } 268 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) { 269 result = new BasicType( oneType->get_qualifiers(), BasicType::SignedInt ); 270 result->get_qualifiers() += type2->get_qualifiers(); 269 271 } 270 272 }
Note: See TracChangeset
for help on using the changeset viewer.