diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp
index ab786c6..218f16f 100644
--- a/lib/Sema/JumpDiagnostics.cpp
+++ b/lib/Sema/JumpDiagnostics.cpp
@@ -173,6 +173,9 @@ static ScopePair GetDiagForGotoScopeDecl(ASTContext &Context, const Decl *D) {
         unsigned inDiagToUse = diag::note_protected_by_variable_init;
 
         const CXXRecordDecl *record = 0;
+        if (const ExprWithCleanups *ec = dyn_cast<ExprWithCleanups>(init)) {
+          init = ec->getSubExpr();
+        }
 
         if (const CXXConstructExpr *cce = dyn_cast<CXXConstructExpr>(init)) {
           const CXXConstructorDecl *ctor = cce->getConstructor();
diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp
index 86d1bd8..b4d3c07 100644
--- a/test/SemaCXX/scope-check.cpp
+++ b/test/SemaCXX/scope-check.cpp
@@ -202,3 +202,16 @@ namespace test10 {
     return 0;
   }
 }
+
+namespace pr13812 {
+  struct C {
+    C(int x);
+    ~C();
+  };
+  void f(void **ip) {
+    static void *ips[] = { &&l0 };
+  l0:  // expected-note {{possible target of indirect goto}}
+    C c0 = 42; // expected-note {{jump exits scope of variable with non-trivial destructor}}
+    goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+  }
+}
