[cfe-commits] r117212 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp
Douglas Gregor
dgregor at apple.com
Sat Oct 23 09:06:17 PDT 2010
Author: dgregor
Date: Sat Oct 23 11:06:17 2010
New Revision: 117212
URL: http://llvm.org/viewvc/llvm-project?rev=117212&view=rev
Log:
C++ [basic.scope.hiding] allows an ordinary name to hide a non-tag
name *in the same scope*, but not across scopes. Implement the
highlighted condition.
Added:
cfe/trunk/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=117212&r1=117211&r2=117212&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Sat Oct 23 11:06:17 2010
@@ -407,8 +407,13 @@
// But it's still an error if there are distinct tag types found,
// even if they're not visible. (ref?)
if (HideTags && HasTag && !Ambiguous &&
- (HasFunction || HasNonFunction || HasUnresolved))
- Decls[UniqueTagIndex] = Decls[--N];
+ (HasFunction || HasNonFunction || HasUnresolved)) {
+ if (Decls[UniqueTagIndex]->getDeclContext()->getRedeclContext()->Equals(
+ Decls[UniqueTagIndex? 0 : N-1]->getDeclContext()->getRedeclContext()))
+ Decls[UniqueTagIndex] = Decls[--N];
+ else
+ Ambiguous = true;
+ }
Decls.set_size(N);
Added: cfe/trunk/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp?rev=117212&view=auto
==============================================================================
--- cfe/trunk/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp (added)
+++ cfe/trunk/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp Sat Oct 23 11:06:17 2010
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// rdar4641403
+namespace N {
+ struct X { // expected-note{{candidate found by name lookup}}
+ float b;
+ };
+}
+
+using namespace N;
+
+typedef struct {
+ int a;
+} X; // expected-note{{candidate found by name lookup}}
+
+
+struct Y { };
+void Y(int) { }
+
+void f() {
+ X *x; // expected-error{{reference to 'X' is ambiguous}}
+ Y(1); // okay
+}
+
More information about the cfe-commits
mailing list