changeset 106:596a38ee9c9e

fix setjmp/longjmp with optimization bug (get some warnings)
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Sat, 30 Jan 2016 16:11:01 +0900
parents f9b011216f60
children a03ddd01be7e
files tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Parse/ParseCbC.cpp
diffstat 2 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tools/clang/include/clang/Parse/Parser.h	Sat Jan 30 04:31:53 2016 +0900
+++ b/tools/clang/include/clang/Parse/Parser.h	Sat Jan 30 16:11:01 2016 +0900
@@ -1884,11 +1884,11 @@
   StmtResult CreateSjForContinuationWithTheEnv();
   StmtResult CreateAssignmentStmt(IdentifierInfo* LHSII = 0, IdentifierInfo* RHSII = 0, bool LHSisMemberAccess = false,
                                   bool RHShasAmp = false, IdentifierInfo* extraLHSII = 0, IdentifierInfo* extraRHSII = 0);
-  StmtResult CreateDeclStmt(IdentifierInfo *II = 0, bool isRetCS = false, bool copyType = false, DeclSpec::TST valueType = DeclSpec::TST_int, IdentifierInfo* Name = 0);
+  StmtResult CreateDeclStmt(IdentifierInfo *II = 0, bool isRetCS = false, bool copyType = false, DeclSpec::TST valueType = DeclSpec::TST_int, IdentifierInfo* Name = 0, DeclSpec::TQ TQ = DeclSpec::TQ_unspecified);
   IdentifierInfo* CreateUniqueIdentifierInfo(const char* Name, SourceLocation Loc);
   ParmVarDecl* CreateParam(IdentifierInfo *II = 0, int pointerNum = 0, DeclSpec::TST T = DeclSpec::TST_int);
   Decl* HandleDeclAndChangeDeclType(Declarator &D);
-  void setTST(DeclSpec *DS = 0, DeclSpec::TST T = DeclSpec::TST_int, IdentifierInfo *Name = 0);
+  void setTST(DeclSpec *DS = 0, DeclSpec::TST T = DeclSpec::TST_int, IdentifierInfo *Name = 0, DeclSpec::TQ TQ = DeclSpec::TQ_unspecified);
   void CheckTheSjHeader();
   ExprResult IIToExpr(IdentifierInfo *II, tok::TokenKind Kind);
   StmtResult CreateComplexStmtRet(IdentifierInfo *II, bool IsAddressOfOperand);
--- a/tools/clang/lib/Parse/ParseCbC.cpp	Sat Jan 30 04:31:53 2016 +0900
+++ b/tools/clang/lib/Parse/ParseCbC.cpp	Sat Jan 30 16:11:01 2016 +0900
@@ -140,7 +140,7 @@
 /// examples which are created:
 ///   complex statement:
 ///         ({
-///           struct __CbC_env __CbC_environment;
+///           volatile struct __CbC_env __CbC_environment;
 ///           jmp_buf env_buf;
 ///           return_type retval;
 ///           __CbC_environment.ret_p = &retval;
@@ -177,7 +177,7 @@
   StmtVector CompoundStmts; 
 
   // struct __CbC_env __CbC_environment;
-  innerRes = CreateDeclStmt(__CbC_envII, false, false, DeclSpec::TST_struct, structII);
+  innerRes = CreateDeclStmt(__CbC_envII, false, false, DeclSpec::TST_struct, structII, DeclSpec::TQ_volatile);
   if (innerRes.isUsable())
     CompoundStmts.push_back(innerRes.get());
 
@@ -262,7 +262,7 @@
 /// CreateDeclStmt - Create declaration statement such as "int aaa;".
 /// If isRetCS is true, create code segment for return to C's function. And Name is name of code segment.
 /// If copyType is true, type of variable is copied from callee.
-StmtResult Parser::CreateDeclStmt(IdentifierInfo *II, bool isRetCS, bool copyType, DeclSpec::TST valueType, IdentifierInfo* Name){
+StmtResult Parser::CreateDeclStmt(IdentifierInfo *II, bool isRetCS, bool copyType, DeclSpec::TST valueType, IdentifierInfo* Name, DeclSpec::TQ TQ){
   const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
   SourceLocation Loc = Tok.getLocation();
   DeclGroupPtrTy DeclGPT;
@@ -270,7 +270,7 @@
   DeclSpec *DSp;
   DSp = &DS;
 
-  setTST(&DS, valueType, Name);
+  setTST(&DS, valueType, Name, TQ);
   ParsingDeclarator D(*this, DS, static_cast<Declarator::TheContext>(Declarator::BlockContext));
   D.SetIdentifier(II, Loc);
     
@@ -821,7 +821,7 @@
 
 /// setTST - set TypeSpecifierType(TST) DeclSpec.
 /// TST is specifiers the kind of type such as int, double, char, etc.
-void Parser::setTST(DeclSpec *DS, DeclSpec::TST T, IdentifierInfo* Name){
+void Parser::setTST(DeclSpec *DS, DeclSpec::TST T, IdentifierInfo* Name, DeclSpec::TQ TQ){
   const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
   SourceLocation Loc = Tok.getLocation();
   bool isInvalid = false;
@@ -830,6 +830,11 @@
   CXXScopeSpec SS;
   DS->SetRangeStart(Loc);
   DS->SetRangeEnd(Loc);
+  if (TQ != DeclSpec::TQ_unspecified) {
+    isInvalid = DS->SetTypeQual(DeclSpec::TQ_volatile, Loc, PrevSpec, DiagID,
+                               getLangOpts());
+  }
+
   if (T == DeclSpec::TST_struct) {
     ParsedAttributesWithRange attrs(AttrFactory);
     DeclResult TagOrTempResult = true;