Ignore:
Timestamp:
Nov 6, 2017, 11:11:56 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
a2ea829
Parents:
e706bfd (diff), 121ac13 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/PtrsAssignable.cc

    re706bfd rbbeb908  
    4747
    4848        int ptrsAssignable( Type *src, Type *dest, const TypeEnvironment &env ) {
     49                // std::cerr << "assignable: " << src << " | " << dest << std::endl;
    4950                if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    5051                        EqvClass eqvClass;
     
    5455                } // if
    5556                if ( dynamic_cast< VoidType* >( dest ) ) {
    56                         return 1;
     57                        // void * = T * for any T is unsafe
     58                        // xxx - this should be safe, but that currently breaks the build
     59                        return -1;
    5760                } else {
    5861                        PtrsAssignable ptrs( dest, env );
     
    6568
    6669        void PtrsAssignable::visit( __attribute((unused)) VoidType *voidType ) {
    67                 if ( dynamic_cast< FunctionType* >( dest ) ) {
    68                         result = 0;
    69                 } else {
    70                         result = -1;
     70                if ( ! dynamic_cast< FunctionType* >( dest ) ) {
     71                        // T * = void * is safe for any T that is not a function type.
     72                        // xxx - this should be unsafe...
     73                        result = 1;
    7174                } // if
    7275        }
     
    7578        void PtrsAssignable::visit( __attribute__((unused)) PointerType *pointerType ) {}
    7679        void PtrsAssignable::visit( __attribute__((unused)) ArrayType *arrayType ) {}
    77         void PtrsAssignable::visit( __attribute__((unused)) FunctionType *functionType ) {
    78                 result = -1;
    79         }
     80        void PtrsAssignable::visit( __attribute__((unused)) FunctionType *functionType ) {}
    8081
    8182        void PtrsAssignable::visit(  __attribute__((unused)) StructInstType *inst ) {}
     
    8384
    8485        void PtrsAssignable::visit( EnumInstType * ) {
    85                 if ( dynamic_cast< EnumInstType* >( dest ) ) {
     86                if ( dynamic_cast< BasicType* >( dest ) ) {
     87                        // int * = E *, etc. is safe. This isn't technically correct, as each
     88                        // enum has one basic type that it is compatible with, an that type can
     89                        // differ from enum to enum. Without replicating GCC's internal logic,
     90                        // there is no way to know which type this particular enum is compatible
     91                        // with, so punt on this for now.
    8692                        result = 1;
    87                 } else if ( BasicType *bt = dynamic_cast< BasicType* >( dest ) ) {
    88                         result = bt->get_kind() == BasicType::SignedInt;
    8993                }
    9094        }
     
    9498                EqvClass eqvClass;
    9599                if ( env.lookup( inst->get_name(), eqvClass ) && eqvClass.type ) {
     100                        // T * = S * for any S depends on the type bound to T
    96101                        result = ptrsAssignable( eqvClass.type, dest, env );
    97                 } else {
    98                         result = 0;
    99102                } // if
    100103        }
Note: See TracChangeset for help on using the changeset viewer.