Changeset f28a53a for src/CodeGen


Ignore:
Timestamp:
Oct 7, 2015, 12:42:10 PM (10 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, string, with_gc
Children:
0800284, 50eac1b
Parents:
59cde21 (diff), 1521de20 (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 override-autogen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r59cde21 rf28a53a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 14:33:52 2015
    13 // Update Count     : 222
     12// Last Modified On : Thu Sep 17 15:24:08 2015
     13// Update Count     : 231
    1414//
    1515
     
    190190                if ( designators.size() == 0 ) return;
    191191                for ( DesignatorList::iterator iter = designators.begin(); iter != designators.end(); ++iter ) {
    192                         if ( NameExpr * nm = dynamic_cast< NameExpr * >( *iter ) ) {
     192                        if ( dynamic_cast< NameExpr * >( *iter ) ) {
    193193                                // if expression is a name, then initializing aggregate member
    194194                                output << ".";
     
    392392
    393393        void CodeGenerator::visit( CastExpr *castExpr ) {
    394                 output << "((";
    395                 if ( castExpr->get_results().empty() ) {
    396                         output << "void" ;
    397                 } else {
    398                         output << genType( castExpr->get_results().front(), "" );
    399                 } // if
    400                 output << ")";
    401                 castExpr->get_arg()->accept( *this );
    402                 output << ")";
     394                // if the cast is to an lvalue type, then the cast
     395                // should be dropped, since the result of a cast is
     396                // never an lvalue in C
     397                if ( castExpr->get_results().front()->get_isLvalue() ) {
     398                        castExpr->get_arg()->accept( *this );
     399                } else {
     400                        output << "((";
     401                        if ( castExpr->get_results().empty() ) {
     402                                output << "void" ;
     403                        } else {
     404                                output << genType( castExpr->get_results().front(), "" );
     405                        } // if
     406                        output << ")";
     407                        castExpr->get_arg()->accept( *this );
     408                        output << ")";                 
     409                }
    403410        }
    404411 
Note: See TracChangeset for help on using the changeset viewer.