changeset 9:1d7e5c85e4cf

set return after goto code segment if caller's return value type is code segment or void type.
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Thu, 04 Jul 2013 02:18:09 +0900
parents ac3ff95a8c30
children e3d004bb4de5
files tools/clang/lib/Parse/ParseStmt.cpp
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/clang/lib/Parse/ParseStmt.cpp	Wed Jul 03 12:42:47 2013 +0900
+++ b/tools/clang/lib/Parse/ParseStmt.cpp	Thu Jul 04 02:18:09 2013 +0900
@@ -1637,7 +1637,6 @@
 StmtResult Parser::ParseCbCGotoStatement(ParsedAttributesWithRange &Attrs,StmtVector &Stmts) {
   assert(Tok.is(tok::kw_goto) && "Not a goto stmt!");
   SourceLocation gotoLoc = ConsumeToken();  // eat the 'goto'.
-    
   StmtResult gotoRes;
     
   if (Tok.is(tok::identifier) && NextToken().is(tok::l_paren)) { // 'goto' codeSegment() ';'
@@ -1657,7 +1656,13 @@
 	ConsumeToken();
       return StmtError();
     }
+
     gotoRes = ParseExprStatement();
+
+    // don't need return because it's not code segment to code segment jamp.
+    if (!Actions.getCurFunctionDecl()->getResultType().getTypePtr()->isVoidType())
+      return gotoRes;
+    
   }
   else {
     Diag(Tok, diag::err_expected_ident);