diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-05-04 00:25:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-05-04 00:25:33 +0000 |
commit | 61c6c4415d0f73bd033128ac85f054a0211e7c42 (patch) | |
tree | a2bb41061a453d75b7a96791700013d437ed0cae | |
parent | 4f40ddde58cb9bebcd23eb3ef3c1b399bac4d938 (diff) |
When tag lookup finds something ambiguous, and we're defining a new
tag, filter out those ambiguous names that we found if they aren't
within the declaration context where this newly-defined tag will be
visible.
This is basically a hack, because we really need to fix the lookup of
tag declarations in this case to not find things it
shouldn't. However, it's better than what we had before, and it fixes
<rdar://problem/9168556>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130810 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 13 | ||||
-rw-r--r-- | test/SemaCXX/tag-ambig.cpp | 17 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 975a963574..d5112a2f0c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -6715,6 +6715,19 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // shouldn't be diagnosing. LookupName(Previous, S); + if (Previous.isAmbiguous() && TUK == TUK_Definition) { + LookupResult::Filter F = Previous.makeFilter(); + while (F.hasNext()) { + NamedDecl *ND = F.next(); + if (ND->getDeclContext()->getRedeclContext() != SearchDC) + F.erase(); + } + F.done(); + + if (Previous.isAmbiguous()) + return 0; + } + // Note: there used to be some attempt at recovery here. if (Previous.isAmbiguous()) return 0; diff --git a/test/SemaCXX/tag-ambig.cpp b/test/SemaCXX/tag-ambig.cpp new file mode 100644 index 0000000000..42cb9604b0 --- /dev/null +++ b/test/SemaCXX/tag-ambig.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// <rdar://problem/9168556> +typedef struct Point Point; + +namespace NameSpace { + class Point; +} + +using namespace NameSpace; + +class Test +{ +public: + struct Point { }; + virtual bool testMethod (Test::Point& p) = 0; +}; |