Ignore:
Timestamp:
Jul 26, 2017, 4:26:08 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
2afec66
Parents:
d335627
Message:

Fix various reference features.

  • Eliminate multiple address-ofs resulting from &(T&) [address-of reference-cast].
  • Keep rvalue cast if reference base type is incompatible with rvalue type.
  • Keep pointer qualifiers when eliminating reference types.
  • Add VariableExpr::functionPointer helper function to create variable expressions with function pointer type.
  • Change ConstructorExpr? translation so that it temporarily generates a 'fake' assignment operator rather than use UntypedExpr?, so that the correct transformations occur in the Lvalue pass. This is a hack that can be fixed once PassVisitor? properly supports Indexer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rd335627 r8a6cf7e  
    661661                extension( commaExpr );
    662662                output << "(";
     663                if ( genC ) {
     664                        // arg1 of a CommaExpr is never used, so it can be safely cast to void to reduce gcc warnings.
     665                        commaExpr->set_arg1( new CastExpr( commaExpr->get_arg1() ) );
     666                }
    663667                commaExpr->get_arg1()->accept( *this );
    664668                output << " , ";
     
    724728                for ( Statement * stmt : stmts ) {
    725729                        output << lineDirective( stmt ) << indent;
    726             output << printLabels( stmt->get_labels() );
     730                        output << printLabels( stmt->get_labels() );
    727731                        if ( i+1 == numStmts ) {
    728732                                // last statement in a statement expression needs to be handled specially -
     
    769773        void CodeGenerator::visit( ExprStmt * exprStmt ) {
    770774                assert( exprStmt );
    771                 Expression * expr = exprStmt->get_expr();
    772775                if ( genC ) {
    773776                        // cast the top-level expression to void to reduce gcc warnings.
    774                         expr = new CastExpr( expr );
    775                 }
    776                 expr->accept( *this );
     777                        exprStmt->set_expr( new CastExpr( exprStmt->get_expr() ) );
     778                }
     779                exprStmt->get_expr()->accept( *this );
    777780                output << ";";
    778781        }
Note: See TracChangeset for help on using the changeset viewer.