Changeset c8fcda2


Ignore:
Timestamp:
Sep 15, 2015, 1:58:38 PM (9 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:
334ebc23
Parents:
830c21a (diff), 76b48f1 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r830c21a rc8fcda2  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Sep 11 12:59:09 2015
    13 // Update Count     : 223
     12// Last Modified On : Tue Sep 15 13:55:27 2015
     13// Update Count     : 230
    1414//
    1515
     
    324324             
    325325                                  case OT_CALL:
     326                                  case OT_CTOR:
     327                                  case OT_DTOR:
    326328                                        assert( false );
    327329                                        break;
     
    394396
    395397        void CodeGenerator::visit( CastExpr *castExpr ) {
    396                 output << "((";
    397                 if ( castExpr->get_results().empty() ) {
    398                         output << "void" ;
    399                 } else {
    400                         output << genType( castExpr->get_results().front(), "" );
    401                 } // if
    402                 output << ")";
    403                 castExpr->get_arg()->accept( *this );
    404                 output << ")";
     398                // if the cast is to an lvalue type, then the cast
     399                // should be dropped, since the result of a cast is
     400                // never an lvalue in C
     401                if ( castExpr->get_results().front()->get_isLvalue() ) {
     402                        castExpr->get_arg()->accept( *this );
     403                } else {
     404                        output << "((";
     405                        if ( castExpr->get_results().empty() ) {
     406                                output << "void" ;
     407                        } else {
     408                                output << genType( castExpr->get_results().front(), "" );
     409                        } // if
     410                        output << ")";
     411                        castExpr->get_arg()->accept( *this );
     412                        output << ")";                 
     413                }
    405414        }
    406415 
Note: See TracChangeset for help on using the changeset viewer.