]> granicus.if.org Git - clang/commitdiff
Fix typo correction usage of SemaAccess.cpp.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 1 Oct 2013 02:44:48 +0000 (02:44 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 1 Oct 2013 02:44:48 +0000 (02:44 +0000)
When we check access for lookup results, make sure we propagate the
result's access to the access control APIs; this can be different from
the natural access of the declaration depending on the path used by the lookup.

PR17394.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191726 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaAccess.cpp
lib/Sema/SemaLookup.cpp
test/SemaCXX/typo-correction-pt2.cpp

index 116b427266eb4e8a7c7b603d726012fbc09c6036..378245585abe907de4527568aae62e0e5d8255bb 100644 (file)
@@ -4896,7 +4896,7 @@ public:
   AccessResult CheckFriendAccess(NamedDecl *D);
   AccessResult CheckMemberAccess(SourceLocation UseLoc,
                                  CXXRecordDecl *NamingClass,
-                                 NamedDecl *D);
+                                 DeclAccessPair Found);
   AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
                                          Expr *ObjectExpr,
                                          Expr *ArgExpr,
index 6dbfad4e18db51faf2c9be3fef0850e229ea90cb..974f3b42db102b8b1a5d7eb2a774e7a4d5f4ceaa 100644 (file)
@@ -1390,8 +1390,6 @@ static AccessResult IsAccessible(Sema &S,
   CXXBasePath *Path = FindBestPath(S, EC, Entity, FinalAccess, Paths);
   if (!Path)
     return AR_dependent;
-  if (Path->Access == AS_none)  // This can happen during typo correction.
-    return AR_inaccessible;
 
   assert(Path->Access <= UnprivilegedAccess &&
          "access along best path worse than direct?");
@@ -1716,14 +1714,14 @@ Sema::AccessResult Sema::CheckAllocationAccess(SourceLocation OpLoc,
 /// \brief Checks access to a member.
 Sema::AccessResult Sema::CheckMemberAccess(SourceLocation UseLoc,
                                            CXXRecordDecl *NamingClass,
-                                           NamedDecl *D) {
+                                           DeclAccessPair Found) {
   if (!getLangOpts().AccessControl ||
       !NamingClass ||
-      D->getAccess() == AS_public)
+      Found.getAccess() == AS_public)
     return AR_accessible;
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass,
-                      DeclAccessPair::make(D, D->getAccess()), QualType());
+                      Found, QualType());
 
   return CheckAccess(*this, UseLoc, Entity);
 }
index c2e23c7ede46bd11c95dd053925a1ecadff12a99..2a096cfd978148a7101b6845a6bcfb85c64507c0 100644 (file)
@@ -4409,7 +4409,7 @@ retry_lookup:
                  TRD != TRDEnd; ++TRD) {
               if (CheckMemberAccess(TC.getCorrectionRange().getBegin(),
                                     NSType ? NSType->getAsCXXRecordDecl() : 0,
-                                    *TRD) == AR_accessible)
+                                    TRD.getPair()) == AR_accessible)
                 TC.addCorrectionDecl(*TRD);
             }
             if (TC.isResolved())
index 1ccd103ecffe4d1a70d3b5aff10f45a42ff8d79b..9c7fb14ccfd1223feef4e2a8374fc4ac2cae07ac 100644 (file)
@@ -135,3 +135,12 @@ void test() {
     req.set_check(false);  // expected-error-re {{use of undeclared identifier 'req'$}}
 }
 }
+
+namespace PR17394 {
+  class A {
+  protected:
+    long zzzzzzzzzz;
+  };
+  class B : private A {};
+  B zzzzzzzzzy<>; // expected-error {{expected ';' after top level declarator}}{}
+}