PR12788: Remove unnecessary and incorrect special case for indirect fields.
This caused us to skip a step that was essential for correct access control.
llvm-svn: 199522
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 1a08c5b..dea4467 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1752,14 +1752,7 @@
assert(!R.empty() && !R.isAmbiguous());
SourceLocation loc = R.getNameLoc();
-
- // We may have found a field within an anonymous union or struct
- // (C++ [class.union]).
- // FIXME: template-ids inside anonymous structs?
- if (IndirectFieldDecl *FD = R.getAsSingle<IndirectFieldDecl>())
- return BuildAnonymousStructUnionMemberReference(SS, R.getNameLoc(), FD,
- R.begin().getPair());
-
+
// If this is known to be an instance access, go ahead and build an
// implicit 'this' expression now.
// 'this' expression now.
diff --git a/clang/test/CXX/class.access/class.access.base/p1.cpp b/clang/test/CXX/class.access/class.access.base/p1.cpp
index 43cc99e..88e2688 100644
--- a/clang/test/CXX/class.access/class.access.base/p1.cpp
+++ b/clang/test/CXX/class.access/class.access.base/p1.cpp
@@ -153,3 +153,18 @@
t->Base::spriv++; // expected-error 2 {{private member}}
}
}
+
+namespace PR12788 {
+ class A {
+ protected:
+ struct {
+ int x;
+ };
+ };
+ class B : A {
+ void f() {
+ ++x;
+ A::x++;
+ }
+ };
+}