Author: dgregor
Date: Tue May 3 19:25:33 2011
New Revision: 130810
URL: http://llvm.org/viewvc/llvm-project?rev=130810&view=rev
Log:
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>.
Added:
cfe/trunk/test/SemaCXX/tag-ambig.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=130810&r1=130809&r2=130810&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 3 19:25:33 2011
@@ -6715,6 +6715,19 @@
// 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;
Added: cfe/trunk/test/SemaCXX/tag-ambig.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/tag-ambig.cpp?rev=130810&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/tag-ambig.cpp (added)
+++ cfe/trunk/test/SemaCXX/tag-ambig.cpp Tue May 3 19:25:33 2011
@@ -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;
+};
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits