Changeset 2c57025 for src/ResolvExpr/CommonType.cc
- Timestamp:
- Nov 25, 2016, 6:11:03 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:
- 0f35657
- Parents:
- 186fd86
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CommonType.cc
r186fd86 r2c57025 57 57 Type *result = visitor.get_result(); 58 58 if ( ! result ) { 59 // this appears to be handling for opaque type declarations 59 60 if ( widenSecond ) { 60 TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ); 61 if ( inst ) { 62 NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ); 63 if ( nt ) { 64 TypeDecl *type = dynamic_cast< TypeDecl* >( nt ); 65 assert( type ); 61 if ( TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ) ) { 62 if ( NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ) ) { 63 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt ); 66 64 if ( type->get_base() ) { 67 65 Type::Qualifiers tq1 = type1->get_qualifiers(), tq2 = type2->get_qualifiers(); … … 145 143 } 146 144 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(); 149 } 150 return false; 151 } 152 147 153 void CommonType::visit( PointerType *pointerType ) { 148 154 if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) { 149 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) ) { 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() ) ) { 150 164 result = otherPointer->clone(); 151 165 result->get_qualifiers() += pointerType->get_qualifiers(); … … 211 225 NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ); 212 226 if ( nt ) { 213 TypeDecl *type = dynamic_cast< TypeDecl* >( nt ); 214 assert( type ); 227 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt ); 215 228 if ( type->get_base() ) { 216 229 Type::Qualifiers tq1 = inst->get_qualifiers(), tq2 = type2->get_qualifiers();
Note: See TracChangeset
for help on using the changeset viewer.