changeset 88:e471d82fb99b

add SearchCodeSegmentDeclaration()
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Mon, 13 Apr 2015 18:34:22 +0900
parents ff9ec87918d4
children 9020ffd06b8b
files tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Parse/ParseCbC.cpp tools/clang/lib/Parse/ParseStmt.cpp
diffstat 3 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tools/clang/include/clang/Parse/Parser.h	Mon Apr 13 15:18:58 2015 +0900
+++ b/tools/clang/include/clang/Parse/Parser.h	Mon Apr 13 18:34:22 2015 +0900
@@ -1803,6 +1803,7 @@
   ExprResult Prepare__retForGotoWithTheEnvExpr();
   ExprResult Prepare__envForGotoWithTheEnvExpr();
   bool isVoidFunction();
+  bool SearchCodeSegmentDeclaration(std::string Name);
 #endif
 
   bool isDeclarationSpecifier(bool DisambiguatingWithExpression = false);
--- a/tools/clang/lib/Parse/ParseCbC.cpp	Mon Apr 13 15:18:58 2015 +0900
+++ b/tools/clang/lib/Parse/ParseCbC.cpp	Mon Apr 13 18:34:22 2015 +0900
@@ -926,4 +926,14 @@
   }
   return Actions.ActOnCompoundStmt(gotoLoc, Tok.getLocation(), CompoundedStmts, false);
 }
+
+/// SearchCodeSegmentDeclaration - Read tokens until we get to the specified code segment declaration.
+/// If we can't find it , return false;
+bool Parser::SearchCodeSegmentDeclaration(std::string Name){
+  while(SkipUntil(tok::kw___code,StopBeforeMatch)){
+    if(NextToken().getIdentifierInfo()->getName().str() == Name)
+      return true;
+  }
+  return false;
+}
 #endif
--- a/tools/clang/lib/Parse/ParseStmt.cpp	Mon Apr 13 15:18:58 2015 +0900
+++ b/tools/clang/lib/Parse/ParseStmt.cpp	Mon Apr 13 18:34:22 2015 +0900
@@ -256,6 +256,16 @@
     if (!(NextToken().is(tok::identifier) && PP.LookAhead(1).is(tok::semi)) && // C: 'goto' identifier ';'
         NextToken().isNot(tok::star)) {                                        // C: 'goto' '*' expression ';'
       SemiError = "goto code segment";
+
+      if(NextToken().is(tok::identifier)){ // Probably, direct continuation. goto csName();
+        LookupResult LR(Actions, NextToken().getIdentifierInfo(), NextToken().getLocation(), Actions.LookupOrdinaryName);
+        CXXScopeSpec SS;
+        Actions.LookupParsedName(LR, getCurScope(), &SS, !(Actions.getCurMethodDecl()));
+        if(LR.getResultKind() == LookupResult::NotFound){
+        }
+        
+      }
+      
       return ParseCbCGotoStatement(Attrs, Stmts);                              // CbC: goto codesegment statement
     }
 #endif