Reset the found-virtual-base state unless the *current* base produces a path,
not *any* base up to now has produced a path.  Fixes PR 6254.

I'll do the access-control part of this patch RSN.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95638 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp
index 7208328..7d9e553 100644
--- a/lib/AST/CXXInheritance.cpp
+++ b/lib/AST/CXXInheritance.cpp
@@ -215,10 +215,13 @@
         Paths.ScratchPath.Access
           = MergeAccess(AccessToHere, BaseSpec->getAccessSpecifier());
     }
-        
+    
+    // Track whether there's a path involving this specific base.
+    bool FoundPathThroughBase = false;
+    
     if (BaseMatches(BaseSpec, Paths.ScratchPath, UserData)) {
       // We've found a path that terminates at this base.
-      FoundPath = true;
+      FoundPath = FoundPathThroughBase = true;
       if (Paths.isRecordingPaths()) {
         // We have a path. Make a copy of it before moving on.
         Paths.Paths.push_back(Paths.ScratchPath);
@@ -240,7 +243,7 @@
         
         // There is a path to a base class that meets the criteria. If we're 
         // not collecting paths or finding ambiguities, we're done.
-        FoundPath = true;
+        FoundPath = FoundPathThroughBase = true;
         if (!Paths.isFindingAmbiguities())
           return FoundPath;
       }
@@ -253,7 +256,7 @@
     }
 
     // If we set a virtual earlier, and this isn't a path, forget it again.
-    if (SetVirtual && !FoundPath) {
+    if (SetVirtual && !FoundPathThroughBase) {
       Paths.DetectedVirtual = 0;
     }
   }