Properly set the scope of non-fields declared within a struct, union,
or enum to be outside that struct, union, or enum. Fixes several
regressions: 

  <rdar://problem/6487662>
  <rdar://problem/6487669>
  <rdar://problem/6487684>
  <rdar://problem/6487702>
  PR clang/3305
  PR clang/3312

There is still some work to do in Objective-C++, but this requires
that each of the Objective-C entities (interfaces, implementations,
etc.) to be introduced into the context stack with
PushDeclContext/PopDeclContext. This will be a separate fix, later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62091 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/type-spec-struct-union.c b/test/Sema/type-spec-struct-union.c
index 38e57f7..47de16b 100644
--- a/test/Sema/type-spec-struct-union.c
+++ b/test/Sema/type-spec-struct-union.c
@@ -35,3 +35,31 @@
 }
 
 void f(struct S5 { int y; } s5); // expected-warning{{declaration of 'struct S5' will not be visible outside of this function}}
+
+// PR clang/3312
+struct S6 {
+        enum { BAR } e;
+};
+
+void test_S6() {
+        struct S6 a;
+        a.e = BAR;
+}
+
+// <rdar://problem/6487669>
+typedef struct z_foo_s {
+  struct bar_baz *baz;
+} z_foo;
+typedef z_foo *z_foop;
+struct bar_baz {
+  enum {
+    SQUAT, FLAG, DICT4, DICT3, DICT2, DICT1, DICT0, HOP, CHECK4, CHECK3, CHECK2, CHECK1, DONE, BAD
+  } mode;
+  int             nowrap;
+};
+int 
+wizbiz_quxPoof(z)
+  z_foop       z;
+{
+  z->baz->mode = z->baz->nowrap ? HOP : SQUAT;
+}