Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r066d77a r486341f  
    307307                                                } else {
    308308                                                        // no address-of operator, so must be a pointer - add dereference
    309                                                         // NOTE: if the assertion starts to trigger, check that the application expr isn't being shared.
    310                                                         // Since its arguments are modified here, this assertion most commonly triggers when the application
    311                                                         // is visited multiple times.
    312309                                                        UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    313310                                                        newExpr->get_args().push_back( *arg );
    314                                                         Type * type = InitTweak::getPointerBase( (*arg)->get_result() );
    315                                                         assertf( type, "First argument to a derefence must be a pointer. Ensure that expressions are not being shared." );
    316                                                         newExpr->set_result( type->clone() );
     311                                                        assert( (*arg)->get_results().size() == 1 );
     312                                                        Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() );
     313                                                        assert( type );
     314                                                        newExpr->get_results().push_back( type->clone() );
    317315                                                        *arg = newExpr;
    318316                                                } // if
     
    529527                extension( castExpr );
    530528                output << "(";
    531                 if ( castExpr->get_result()->isVoid() ) {
     529                if ( castExpr->get_results().empty() ) {
    532530                        output << "(void)" ;
    533                 } else if ( ! castExpr->get_result()->get_isLvalue() ) {
     531                } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
    534532                        // at least one result type of cast, but not an lvalue
    535533                        output << "(";
    536                         output << genType( castExpr->get_result(), "" );
     534                        output << genType( castExpr->get_results().front(), "" );
    537535                        output << ")";
    538536                } else {
     
    642640        }
    643641
    644         void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); }
     642        void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
    645643
    646644        void CodeGenerator::visit( TypeExpr * typeExpr ) {}
     
    656654                asmExpr->get_operand()->accept( *this );
    657655                output << " )";
    658         }
    659 
    660         void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) {
    661                 assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
    662                 output << "(" << genType( compLitExpr->get_type(), "" ) << ")";
    663                 compLitExpr->get_initializer()->accept( *this );
    664         }
    665 
    666         void CodeGenerator::visit( StmtExpr * stmtExpr ) {
    667                 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
    668                 output << "({" << std::endl;
    669                 cur_indent += CodeGenerator::tabsize;
    670                 unsigned int numStmts = stmts.size();
    671                 unsigned int i = 0;
    672                 for ( Statement * stmt : stmts ) {
    673                         output << indent << printLabels( stmt->get_labels() );
    674                         if ( i+1 == numStmts ) {
    675                                 // last statement in a statement expression needs to be handled specially -
    676                                 // cannot cast to void, otherwise the expression statement has no value
    677                                 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
    678                                         exprStmt->get_expr()->accept( *this );
    679                                         output << ";" << endl;
    680                                         ++i;
    681                                         break;
    682                                 }
    683                         }
    684                         stmt->accept( *this );
    685                         output << endl;
    686                         if ( wantSpacing( stmt ) ) {
    687                                 output << endl;
    688                         } // if
    689                         ++i;
    690                 }
    691                 cur_indent -= CodeGenerator::tabsize;
    692                 output << indent << "})";
    693656        }
    694657
Note: See TracChangeset for help on using the changeset viewer.