r199522 - PR12788: Remove unnecessary and incorrect special case for indirect fields.
Richard Smith
richard-llvm at metafoo.co.uk
Fri Jan 17 14:29:44 PST 2014
Author: rsmith
Date: Fri Jan 17 16:29:43 2014
New Revision: 199522
URL: http://llvm.org/viewvc/llvm-project?rev=199522&view=rev
Log:
PR12788: Remove unnecessary and incorrect special case for indirect fields.
This caused us to skip a step that was essential for correct access control.
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp
Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=199522&r1=199521&r2=199522&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Fri Jan 17 16:29:43 2014
@@ -1752,14 +1752,7 @@ Sema::BuildImplicitMemberExpr(const CXXS
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.
Modified: cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp?rev=199522&r1=199521&r2=199522&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.access.base/p1.cpp Fri Jan 17 16:29:43 2014
@@ -153,3 +153,18 @@ namespace test2 {
t->Base::spriv++; // expected-error 2 {{private member}}
}
}
+
+namespace PR12788 {
+ class A {
+ protected:
+ struct {
+ int x;
+ };
+ };
+ class B : A {
+ void f() {
+ ++x;
+ A::x++;
+ }
+ };
+}
More information about the cfe-commits
mailing list