Changes in src/CodeGen/CodeGenerator.cc [066d77a:486341f]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r066d77a r486341f 307 307 } else { 308 308 // 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 application311 // is visited multiple times.312 309 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 313 310 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() ); 317 315 *arg = newExpr; 318 316 } // if … … 529 527 extension( castExpr ); 530 528 output << "("; 531 if ( castExpr->get_result ()->isVoid() ) {529 if ( castExpr->get_results().empty() ) { 532 530 output << "(void)" ; 533 } else if ( ! castExpr->get_result ()->get_isLvalue() ) {531 } else if ( ! castExpr->get_results().front()->get_isLvalue() ) { 534 532 // at least one result type of cast, but not an lvalue 535 533 output << "("; 536 output << genType( castExpr->get_result (), "" );534 output << genType( castExpr->get_results().front(), "" ); 537 535 output << ")"; 538 536 } else { … … 642 640 } 643 641 644 void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false );}642 void CodeGenerator::visit( TupleExpr * tupleExpr ) {} 645 643 646 644 void CodeGenerator::visit( TypeExpr * typeExpr ) {} … … 656 654 asmExpr->get_operand()->accept( *this ); 657 655 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 value677 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 } // if689 ++i;690 }691 cur_indent -= CodeGenerator::tabsize;692 output << indent << "})";693 656 } 694 657
Note:
See TracChangeset
for help on using the changeset viewer.