Changeset 33e6a2cc for src/ResolvExpr


Ignore:
Timestamp:
Feb 26, 2016, 3:59:15 PM (9 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
540ddb7d
Parents:
931dd12 (diff), ac1ed49 (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
  • TabularUnified src/ResolvExpr/Unify.cc

    r931dd12 r33e6a2cc  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Unify.cc -- 
     7// Unify.cc --
    88//
    99// Author           : Richard C. Bilson
     
    3838                WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
    3939                operator bool() { return widenFirst && widenSecond; }
    40  
     40
    4141                bool widenFirst : 1, widenSecond : 1;
    4242        };
     
    4545          public:
    4646                Unify( Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
    47  
     47
    4848                bool get_result() const { return result; }
    4949          private:
     
    7979        bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer, Type *&common );
    8080        bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
    81  
     81
    8282        bool typesCompatible( Type *first, Type *second, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    8383                TypeEnvironment newEnv;
     
    137137                  case TypeDecl::Dtype:
    138138                        return ! isFtype( type, indexer );
    139  
     139
    140140                  case TypeDecl::Ftype:
    141141                        return isFtype( type, indexer );
     
    196196                bool widen1 = false, widen2 = false;
    197197                Type *type1 = 0, *type2 = 0;
    198  
     198
    199199                if ( env.lookup( var1->get_name(), class1 ) ) {
    200200                        hasClass1 = true;
     
    217217                        widen2 = widenMode.widenSecond && class2.allowWidening;
    218218                } // if
    219  
     219
    220220                if ( type1 && type2 ) {
    221221//    std::cout << "has type1 && type2" << std::endl;
     
    436436                // to unify, array types must both be VLA or both not VLA
    437437                // and must both have a dimension expression or not have a dimension
    438                 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen()
    439                                 && ((arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0)
    440                                         || (arrayType->get_dimension() == 0 && otherArray->get_dimension() == 0))) {
     438                if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) {
    441439
    442440                        // not positive this is correct in all cases, but it's needed for typedefs
     
    449447                                ConstantExpr * ce1 = dynamic_cast< ConstantExpr * >( arrayType->get_dimension() );
    450448                                ConstantExpr * ce2 = dynamic_cast< ConstantExpr * >( otherArray->get_dimension() );
    451                                 assert(ce1 && ce2);
    452 
    453                                 Constant * c1 = ce1->get_constant();
    454                                 Constant * c2 = ce2->get_constant();
    455 
    456                                 if ( c1->get_value() != c2->get_value() ) {
    457                                         // does not unify if the dimension is different
    458                                         return;
     449                                // see C11 Reference Manual 6.7.6.2.6
     450                                // two array types with size specifiers that are integer constant expressions are
     451                                // compatible if both size specifiers have the same constant value
     452                                if ( ce1 && ce2 ) {
     453                                        Constant * c1 = ce1->get_constant();
     454                                        Constant * c2 = ce2->get_constant();
     455
     456                                        if ( c1->get_value() != c2->get_value() ) {
     457                                                // does not unify if the dimension is different
     458                                                return;
     459                                        }
    459460                                }
    460461                        }
     
    485486
    486487                        if ( unifyDeclList( functionType->get_parameters().begin(), functionType->get_parameters().end(), otherFunction->get_parameters().begin(), otherFunction->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
    487        
     488
    488489                                if ( unifyDeclList( functionType->get_returnVals().begin(), functionType->get_returnVals().end(), otherFunction->get_returnVals().begin(), otherFunction->get_returnVals().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
    489490
Note: See TracChangeset for help on using the changeset viewer.