summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/qual-id-test.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-02 22:59:36 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-02 22:59:36 +0000
commitb7bfe794129f3b6f990c576dedee0452c6955ac5 (patch)
tree5619b84298ddfe8966133b452d02ee317fc986c1 /clang/test/SemaCXX/qual-id-test.cpp
parentef7c1fd9090b82ac1f96a2bf4959ebae77701930 (diff)
downloadbcm5719-llvm-b7bfe794129f3b6f990c576dedee0452c6955ac5.tar.gz
bcm5719-llvm-b7bfe794129f3b6f990c576dedee0452c6955ac5.zip
Rewrite of our handling of name lookup in C++ member access expressions, e.g.,
x->Base::f We no longer try to "enter" the context of the type that "x" points to. Instead, we drag that object type through the parser and pass it into the Sema routines that need to know how to perform lookup within member access expressions. We now implement most of the crazy name lookup rules in C++ [basic.lookup.classref] for non-templated code, including performing lookup both in the context of the type referred to by the member access and in the scope of the member access itself and then detecting ambiguities when the two lookups collide (p1 and p4; p3 and p7 are still TODO). This change also corrects our handling of name lookup within template arguments of template-ids inside the nested-name-specifier (p6; we used to look into the scope of the object expression for them) and fixes PR4703. I have disabled some tests that involve member access expressions where the object expression has dependent type, because we don't yet have the ability to describe dependent nested-name-specifiers starting with an identifier. llvm-svn: 80843
Diffstat (limited to 'clang/test/SemaCXX/qual-id-test.cpp')
-rw-r--r--clang/test/SemaCXX/qual-id-test.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/clang/test/SemaCXX/qual-id-test.cpp b/clang/test/SemaCXX/qual-id-test.cpp
index ad013990cac..10f1a47a9d4 100644
--- a/clang/test/SemaCXX/qual-id-test.cpp
+++ b/clang/test/SemaCXX/qual-id-test.cpp
@@ -3,7 +3,7 @@ namespace A
{
namespace B
{
- struct base
+ struct base // expected-note{{object type}}
{
void x() {}
void y() {}
@@ -82,13 +82,31 @@ namespace C
i.foo(); // expected-error{{member reference base type 'int' is not a structure or union}}
}
+ void fun4a() {
+ A::sub *a;
+
+ typedef A::member base; // expected-note{{current scope}}
+ a->base::x(); // expected-error{{ambiguous}}
+ }
+
+ void fun4b() {
+ A::sub *a;
+
+ typedef A::B::base base;
+ a->base::x();
+ }
+
template<typename T>
- void fun4()
+ void fun5()
{
T a;
a.x();
a->foo();
+#if 0
+ // FIXME: We need the notion of identifiers as dependent
+ // nested-name-specifiers without a prefix for this code to work.
+
// Things that work for the wrong reason
a.A::sub::x();
a.A::B::base::x();
@@ -98,9 +116,20 @@ namespace C
a.bad::x();
// Things that fail, but shouldn't
- a.sub::x(); // expected-error{{use of undeclared identifier 'sub'}}
- a.base::x(); // expected-error{{use of undeclared identifier 'base'}}
- a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
- a->member::foo(); // expected-error{{use of undeclared identifier 'member'}}
+ a.sub::x(); // xpected-error{{use of undeclared identifier 'sub'}}
+ a.base::x(); // xpected-error{{use of undeclared identifier 'base'}}
+ a.B::base::x(); // xpected-error{{use of undeclared identifier 'B'}}
+ a->member::foo(); // xpected-error{{use of undeclared identifier 'member'}}
+#endif
}
}
+
+// PR4703
+struct a {
+ int a;
+ static int sa;
+};
+
+a a;
+
+int a::sa = a.a;
OpenPOWER on IntegriCloud