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