Fix member refs with using decl + anonymous union.

Make sure we call BuildFieldReferenceExpr with the appropriate decl
when a member of an anonymous union is made public with a using decl.
Also, fix a crash on invalid field access into an anonymous union.

Fixes PR16630.

llvm-svn: 186367
diff --git a/clang/test/SemaCXX/anonymous-union.cpp b/clang/test/SemaCXX/anonymous-union.cpp
index 9c2cf24..fde27b04 100644
--- a/clang/test/SemaCXX/anonymous-union.cpp
+++ b/clang/test/SemaCXX/anonymous-union.cpp
@@ -197,3 +197,12 @@
 
   Foo<int> baz;
 }
+
+namespace PR16630 {
+  struct A { union { int x; float y; }; }; // expected-note {{member is declared here}}
+  struct B : private A { using A::x; } b; // expected-note 2 {{private}}
+  void foo () {
+    b.x = 10;
+    b.y = 0; // expected-error {{cannot cast 'struct B' to its private base class 'PR16630::A'}} expected-error {{'y' is a private member of 'PR16630::A'}}
+  }
+}