summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaLookup.cpp28
-rw-r--r--clang/test/FixIt/typo.cpp5
-rw-r--r--clang/test/Sema/switch.c2
3 files changed, 19 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 9ed15225b49..897ce200758 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2000,6 +2000,19 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result,
if (!S)
return;
+ if (!S->getEntity() || !S->getParent() ||
+ ((DeclContext *)S->getEntity())->isFunctionOrMethod()) {
+ // Walk through the declarations in this Scope.
+ for (Scope::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
+ D != DEnd; ++D) {
+ if (NamedDecl *ND = dyn_cast<NamedDecl>((Decl *)((*D).get())))
+ if (Result.isAcceptableDecl(ND)) {
+ Consumer.FoundDecl(ND, Visited.checkHidden(ND));
+ Visited.add(ND);
+ }
+ }
+ }
+
DeclContext *Entity = 0;
if (S->getEntity()) {
// Look into this scope's declaration context, along with any of its
@@ -2041,22 +2054,11 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result,
// doing so would force the normal C++ name-lookup code to look into the
// translation unit decl when the IdentifierInfo chains would suffice.
// Once we fix that problem (which is part of a more general "don't look
- // in DeclContexts unless we have to" optimization), we can eliminate the
- // TranslationUnit parameter entirely.
+ // in DeclContexts unless we have to" optimization), we can eliminate this.
Entity = Result.getSema().Context.getTranslationUnitDecl();
LookupVisibleDecls(Entity, Result, /*QualifiedNameLookup=*/false,
Consumer, Visited);
- } else {
- // Walk through the declarations in this Scope.
- for (Scope::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
- D != DEnd; ++D) {
- if (NamedDecl *ND = dyn_cast<NamedDecl>((Decl *)((*D).get())))
- if (Result.isAcceptableDecl(ND)) {
- Consumer.FoundDecl(ND, Visited.checkHidden(ND));
- Visited.add(ND);
- }
- }
- }
+ }
if (Entity) {
// Lookup visible declarations in any namespaces found by using
diff --git a/clang/test/FixIt/typo.cpp b/clang/test/FixIt/typo.cpp
index 50c6d312b8c..c0570258c53 100644
--- a/clang/test/FixIt/typo.cpp
+++ b/clang/test/FixIt/typo.cpp
@@ -21,8 +21,9 @@ tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?
::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
-float area(float radius, float pi) {
- return radious * pi; // expected-error{{use of undeclared identifier 'radious'; did you mean 'radius'?}}
+float area(float radius, // expected-note{{'radius' declared here}}
+ float pi) {
+ return radious * pi; // expected-error{{did you mean 'radius'?}}
}
bool test_string(std::string s) {
diff --git a/clang/test/Sema/switch.c b/clang/test/Sema/switch.c
index f815ba4627f..08ab0e0ebd7 100644
--- a/clang/test/Sema/switch.c
+++ b/clang/test/Sema/switch.c
@@ -76,7 +76,7 @@ void test6() {
}
// PR5606
-int f0(int var) {
+int f0(int var) { // expected-note{{'var' declared here}}
switch (va) { // expected-error{{use of undeclared identifier 'va'}}
case 1:
break;
OpenPOWER on IntegriCloud