Changeset 771b3c3 for src


Ignore:
Timestamp:
Jan 20, 2016, 1:09:05 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, with_gc
Children:
d63eeb0
Parents:
ca1c11f (diff), 803deb1 (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' into ctor

Conflicts:

src/CodeGen/CodeGenerator.cc
src/GenPoly/Specialize.cc

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rca1c11f r771b3c3  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Jan 19 13:15:44 2016
    13 // Update Count     : 251
     12// Last Modified On : Wed Jan 20 12:59:17 2016
     13// Update Count     : 254
    1414//
    1515
     
    408408
    409409        void CodeGenerator::visit( CastExpr *castExpr ) {
    410                 // if the cast is to an lvalue type, then the cast
    411                 // should be dropped, since the result of a cast is
    412                 // never an lvalue in C
    413                 if ( castExpr->get_results().front()->get_isLvalue() ) {
    414                         castExpr->get_arg()->accept( *this );
    415                 } else {
    416                         output << "((";
    417                         if ( castExpr->get_results().empty() ) {
    418                                 output << "void" ;
    419                         } else {
    420                                 output << genType( castExpr->get_results().front(), "" );
    421                         } // if
     410                output << "(";
     411                if ( castExpr->get_results().empty() ) {
     412                        output << "(void)" ;
     413                } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
     414                        // at least one result type of cast, but not an lvalue
     415                        output << "(";
     416                        output << genType( castExpr->get_results().front(), "" );
    422417                        output << ")";
    423                         castExpr->get_arg()->accept( *this );
    424                         output << ")";
     418                } else {
     419                        // otherwise, the cast is to an lvalue type, so the cast
     420                        // should be dropped, since the result of a cast is
     421                        // never an lvalue in C
    425422                }
     423                castExpr->get_arg()->accept( *this );
     424                output << ")";
    426425        }
    427426
  • src/GenPoly/Specialize.cc

    rca1c11f r771b3c3  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Jan 19 10:40:37 2016
    13 // Update Count     : 23
     12// Last Modified On : Wed Jan 20 13:00:00 2016
     13// Update Count     : 24
    1414//
    1515
     
    142142
    143143        Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) {
    144                 assert( actual->get_results().size() >= 1 ); // using front, should have this assert
     144                assert( ! actual->get_results().empty() ); // using front, should have this assert
    145145                if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
    146146                        FunctionType *funType;
     
    198198
    199199        Expression * Specialize::mutate( CastExpr *castExpr ) {
    200                 assert( castExpr->get_results().size() >= 1 && "Check that functions with void return aren't returning a value" );
    201200                castExpr->get_arg()->acceptMutator( *this );
     201                if ( castExpr->get_results().empty() ) {
     202                        // can't specialize if we don't have a return value
     203                        return castExpr;
     204                }
    202205                Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() );
    203206                if ( specialized != castExpr->get_arg() ) {
Note: See TracChangeset for help on using the changeset viewer.