]> granicus.if.org Git - clang/commitdiff
When typo correction produces a result that is not of the kind we're
authorDouglas Gregor <dgregor@apple.com>
Tue, 29 Jun 2010 19:27:42 +0000 (19:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 29 Jun 2010 19:27:42 +0000 (19:27 +0000)
looking for, reset the name within the LookupResult structure in
addition to clearing out the results. Fixes PR7508.

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

lib/Sema/SemaCXXScopeSpec.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaTemplate.cpp
test/SemaCXX/member-expr.cpp

index c0ec9e997d1359b325ffb716ddf575cf4f082cf6..42c346fbe83dc215ba8651a95bf9c501579952fd 100644 (file)
@@ -458,8 +458,10 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
       if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
         Diag(ND->getLocation(), diag::note_previous_decl)
           << ND->getDeclName();
-    } else
+    } else {
       Found.clear();
+      Found.setLookupName(&II);
+    }
   }
 
   NamedDecl *SD = Found.getAsSingle<NamedDecl>();
index bf75773f6d0ca92646daa6fb298f29d00f86fb0a..63452f9cbc496998a4b74a7d24e11bce6667464e 100644 (file)
@@ -1139,6 +1139,7 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
             return true;
 
           R.clear();
+          R.setLookupName(MemberOrBase);
         }
       }
 
@@ -3516,6 +3517,9 @@ Sema::DeclPtrTy Sema::ActOnUsingDirective(Scope *S,
           << Corrected;
         
         NamespcName = Corrected.getAsIdentifierInfo();
+      } else {
+        R.clear();
+        R.setLookupName(NamespcName);
       }
     }
   }
@@ -4240,6 +4244,9 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
           << Corrected;
         
         Ident = Corrected.getAsIdentifierInfo();
+      } else {
+        R.clear();
+        R.setLookupName(Ident);
       }
     }
     
index e5c8e973c531bea24e41ecae7642b883b9558c7f..ae16d57870f80e23926af27dfa1e75f8987899e6 100644 (file)
@@ -2620,6 +2620,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
     return false;
   } else {
     R.clear();
+    R.setLookupName(Name);
   }
 
   return false;
@@ -3080,6 +3081,9 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
                                             IV->getNameAsString());
           Diag(IV->getLocation(), diag::note_previous_decl)
             << IV->getDeclName();
+        } else {
+          Res.clear();
+          Res.setLookupName(Member);
         }
       }
 
index 735809f18546c7eebea89fb7c7443e2db64db580..7e5377ab9a96b399130555ad4b5231700b5b959a 100644 (file)
@@ -258,7 +258,7 @@ void Sema::LookupTemplateName(LookupResult &Found,
     // If we did not find any names, attempt to correct any typos.
     DeclarationName Name = Found.getLookupName();
     if (DeclarationName Corrected = CorrectTypo(Found, S, &SS, LookupCtx, 
-                                                 false, CTC_CXXCasts)) {
+                                                false, CTC_CXXCasts)) {
       FilterAcceptableTemplateNames(Context, Found);
       if (!Found.empty()) {
         if (LookupCtx)
@@ -277,6 +277,7 @@ void Sema::LookupTemplateName(LookupResult &Found,
       }
     } else {
       Found.clear();
+      Found.setLookupName(Name);
     }
   }
 
index e83fdbf0870522097e9d2d662bdd356b0143b228..6830c5fdafb7781de21b917ca97ab4c04ac3a1d7 100644 (file)
@@ -90,3 +90,14 @@ namespace test5 {
     x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}}
   }
 }
+
+namespace PR7508 {
+  struct A {
+    struct CleanupScope {};
+    void PopCleanupBlock();
+  };
+
+  void foo(A &a) {
+    a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'}}
+  }
+}