r264189 - Make SemaAccess smarter about determining when a dependent class might
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 23 13:39:06 PDT 2016
Author: rsmith
Date: Wed Mar 23 15:39:06 2016
New Revision: 264189
URL: http://llvm.org/viewvc/llvm-project?rev=264189&view=rev
Log:
Make SemaAccess smarter about determining when a dependent class might
instantiate to match a friend class declaration. It's still pretty dumb,
though.
Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/SemaCXX/access.cpp
cfe/trunk/www/cxx_dr_status.html
Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=264189&r1=264188&r2=264189&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Wed Mar 23 15:39:06 2016
@@ -291,9 +291,10 @@ static AccessResult IsDerivedFromInclusi
SmallVector<const CXXRecordDecl*, 8> Queue; // actually a stack
while (true) {
- if (Derived->isDependentContext() && !Derived->hasDefinition())
+ if (Derived->isDependentContext() && !Derived->hasDefinition() &&
+ !Derived->isLambda())
return AR_dependent;
-
+
for (const auto &I : Derived->bases()) {
const CXXRecordDecl *RD;
@@ -410,14 +411,8 @@ static AccessResult MatchesFriend(Sema &
return AR_accessible;
if (EC.isDependent()) {
- CanQualType FriendTy
- = S.Context.getCanonicalType(S.Context.getTypeDeclType(Friend));
-
- for (EffectiveContext::record_iterator
- I = EC.Records.begin(), E = EC.Records.end(); I != E; ++I) {
- CanQualType ContextTy
- = S.Context.getCanonicalType(S.Context.getTypeDeclType(*I));
- if (MightInstantiateTo(S, ContextTy, FriendTy))
+ for (const CXXRecordDecl *Context : EC.Records) {
+ if (MightInstantiateTo(Context, Friend))
return AR_dependent;
}
}
Modified: cfe/trunk/test/CXX/drs/dr5xx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr5xx.cpp?rev=264189&r1=264188&r2=264189&view=diff
==============================================================================
--- cfe/trunk/test/CXX/drs/dr5xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr5xx.cpp Wed Mar 23 15:39:06 2016
@@ -814,7 +814,7 @@ namespace dr577 { // dr577: yes
}
}
-namespace dr580 { // dr580: no
+namespace dr580 { // dr580: partial
class C;
struct A { static C c; };
struct B { static C c; };
@@ -822,7 +822,7 @@ namespace dr580 { // dr580: no
C(); // expected-note {{here}}
~C(); // expected-note {{here}}
- typedef int I; // expected-note {{here}}
+ typedef int I; // expected-note 2{{here}}
template<int> struct X;
template<int> friend struct Y;
template<int> void f();
@@ -832,7 +832,20 @@ namespace dr580 { // dr580: no
template<C::I> struct C::X {};
template<C::I> struct Y {};
- template<C::I> struct Z {}; // FIXME: should reject, accepted because C befriends A!
+ template<C::I> struct Z {}; // expected-error {{private}}
+
+ struct C2 {
+ class X {
+ struct A;
+ typedef int I;
+ friend struct A;
+ };
+ class Y {
+ template<X::I> struct A {}; // FIXME: We incorrectly accept this
+ // because we think C2::Y::A<...> might
+ // instantiate to C2::X::A
+ };
+ };
template<C::I> void C::f() {}
template<C::I> void g() {}
Modified: cfe/trunk/test/SemaCXX/access.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/access.cpp?rev=264189&r1=264188&r2=264189&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/access.cpp (original)
+++ cfe/trunk/test/SemaCXX/access.cpp Wed Mar 23 15:39:06 2016
@@ -167,5 +167,5 @@ namespace ThisLambdaIsNotMyFriend {
template <class T> void foo() {
[]() { A::foo(); }(); // expected-error {{private}}
}
- void bar() { foo<void>(); } // expected-note {{instantiation}}
+ void bar() { foo<void>(); }
}
Modified: cfe/trunk/www/cxx_dr_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=264189&r1=264188&r2=264189&view=diff
==============================================================================
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Wed Mar 23 15:39:06 2016
@@ -3523,7 +3523,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#580">580</a></td>
<td>C++11</td>
<td>Access in <I>template-parameter</I>s of member and friend definitions</td>
- <td class="none" align="center">No</td>
+ <td class="partial" align="center">Partial</td>
</tr>
<tr class="open" id="581">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#581">581</a></td>
More information about the cfe-commits
mailing list