Ignore:
Timestamp:
Sep 29, 2016, 10:48:09 AM (9 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:
7e10773
Parents:
7b69174 (diff), 4b1fd2c (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/CommonType.cc

    r7b69174 raee7e35  
    3939                virtual void visit( TupleType *tupleType );
    4040                virtual void visit( VarArgsType *varArgsType );
     41                virtual void visit( ZeroType *zeroType );
     42                virtual void visit( OneType *oneType );
    4143
    4244                template< typename RefType > void handleRefType( RefType *inst, Type *other );
     
    134136                                result = new BasicType( basicType->get_qualifiers() + otherBasic->get_qualifiers(), newType );
    135137                        } // if
    136                 } else if ( EnumInstType *enumInstType = dynamic_cast< EnumInstType * > ( type2 ) ) {
    137                         // use signed int in lieu of the enum type
     138                } else if ( dynamic_cast< EnumInstType * > ( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) {
     139                        // use signed int in lieu of the enum/zero/one type
    138140                        BasicType::Kind newType = combinedType[ basicType->get_kind() ][ BasicType::SignedInt ];
    139                         if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= enumInstType->get_qualifiers() ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->get_qualifiers() <= enumInstType->get_qualifiers() ) || widenSecond ) ) {
    140                                 result = new BasicType( basicType->get_qualifiers() + enumInstType->get_qualifiers(), newType );
     141                        if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= type2->get_qualifiers() ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->get_qualifiers() <= type2->get_qualifiers() ) || widenSecond ) ) {
     142                                result = new BasicType( basicType->get_qualifiers() + type2->get_qualifiers(), newType );
    141143                        } // if
    142144                } // if
     
    171173                                otherPointer->get_base()->get_qualifiers() = tq2;
    172174                        } // if
     175                } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) {
     176                        result = pointerType->clone();
     177                        result->get_qualifiers() += type2->get_qualifiers();
    173178                } // if
    174179        }
     
    190195
    191196        void CommonType::visit( EnumInstType *enumInstType ) {
    192                 if ( dynamic_cast< BasicType * >( type2 ) ) {
     197                if ( dynamic_cast< BasicType * >( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) {
    193198                        // reuse BasicType, EnumInstType code by swapping type2 with enumInstType
    194199                        Type * temp = type2;
     
    230235        void CommonType::visit( VarArgsType *varArgsType ) {
    231236        }
     237
     238        void CommonType::visit( ZeroType *zeroType ) {
     239                if ( widenFirst ) {
     240                        if ( dynamic_cast< BasicType* >( type2 ) || dynamic_cast< PointerType* >( type2 ) || dynamic_cast< EnumInstType* >( type2 ) ) {
     241                                if ( widenSecond || zeroType->get_qualifiers() <= type2->get_qualifiers() ) {
     242                                        result = type2->clone();
     243                                        result->get_qualifiers() += zeroType->get_qualifiers();
     244                                }
     245                        }
     246                }
     247        }
     248
     249        void CommonType::visit( OneType *oneType ) {
     250                if ( widenFirst ) {
     251                        if ( dynamic_cast< BasicType* >( type2 ) || dynamic_cast< EnumInstType* >( type2 ) ) {
     252                                if ( widenSecond || oneType->get_qualifiers() <= type2->get_qualifiers() ) {
     253                                        result = type2->clone();
     254                                        result->get_qualifiers() += oneType->get_qualifiers();
     255                                }
     256                        }
     257                }
     258        }
    232259} // namespace ResolvExpr
    233260
Note: See TracChangeset for help on using the changeset viewer.