Implement an indirect-goto optimization for goto *&&lbl and respect this
in the scope checker.  With that done, turn an indirect goto into a
protected scope into a hard error;  otherwise IR generation has to start
worrying about declarations not dominating their scopes, as exemplified
in PR8473.

If this really affects anyone, I can probably adjust this to only hard-error
on possible indirect gotos into VLA scopes rather than arbitrary scopes.
But we'll see how people cope with the aggressive change on the marginal
feature.

llvm-svn: 117539
diff --git a/clang/test/Sema/scope-check.c b/clang/test/Sema/scope-check.c
index 4ccb64c..1a2fc2b 100644
--- a/clang/test/Sema/scope-check.c
+++ b/clang/test/Sema/scope-check.c
@@ -133,7 +133,7 @@
 void test9(int n, void *P) {
   int Y;
   int Z = 4;
-  goto *P;  // expected-warning {{indirect goto might cross protected scopes}}
+  goto *P;  // expected-error {{indirect goto might cross protected scopes}}
 
 L2: ;
   int a[n]; // expected-note {{jump bypasses initialization of variable length array}}
@@ -199,3 +199,33 @@
  a0: ;
   static void *ps[] = { &&a0 };
 }
+
+int test14(int n) {
+  static void *ps[] = { &&a0, &&a1 };
+  if (n < 0)
+    goto *&&a0;
+
+  if (n > 0) {
+    int vla[n];
+   a1:
+    vla[n-1] = 0;
+  }
+ a0:
+  return 0;
+}
+
+
+// PR8473: IR gen can't deal with indirect gotos past VLA
+// initialization, so that really needs to be a hard error.
+void test15(int n, void *pc) {
+  static const void *addrs[] = { &&L1, &&L2 };
+
+  goto *pc; // expected-error {{indirect goto might cross protected scope}}
+
+ L1:
+  {
+    char vla[n]; // expected-note {{jump bypasses initialization}}
+   L2: // expected-note {{possible target}}
+    vla[0] = 'a';
+  }
+}