[cfe-commits] r150204 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/goto.cpp

Eli Friedman eli.friedman at gmail.com
Thu Feb 9 12:13:15 PST 2012


Author: efriedma
Date: Thu Feb  9 14:13:14 2012
New Revision: 150204

URL: http://llvm.org/viewvc/llvm-project?rev=150204&view=rev
Log:
Make sure a variable with a C++ direct initializer triggers jump scope checking.  Fixes PR10620 / <rdar://problem/9958362> .


Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/goto.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=150204&r1=150203&r2=150204&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Feb  9 14:13:14 2012
@@ -16,6 +16,7 @@
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ScopeInfo.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTMutationListener.h"
@@ -9223,6 +9224,9 @@
     return;
   } 
 
+  if (VDecl->hasLocalStorage())
+    getCurFunction()->setHasBranchProtectedScope();
+
   bool IsDependent = false;
   for (unsigned I = 0, N = Exprs.size(); I != N; ++I) {
     if (DiagnoseUnexpandedParameterPack(Exprs.get()[I], UPPC_Expression)) {

Modified: cfe/trunk/test/SemaCXX/goto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/goto.cpp?rev=150204&r1=150203&r2=150204&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/goto.cpp (original)
+++ cfe/trunk/test/SemaCXX/goto.cpp Thu Feb  9 14:13:14 2012
@@ -103,3 +103,15 @@
  exit:
   return;
 }
+
+namespace PR10620 {
+  struct S {
+    ~S() {}
+  };
+  void g(const S& s) {
+    goto done; // expected-error {{goto into protected scope}}
+    const S s2(s); // expected-note {{jump bypasses variable initialization}}
+  done:
+    ;
+  }
+}





More information about the cfe-commits mailing list