summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-10-15 18:38:02 +0000
committerReid Kleckner <reid@kleckner.net>2013-10-15 18:38:02 +0000
commit916ac4d23323f2d08006bb58e7f61d0feade998a (patch)
tree86df7c1a97d06cd6f3888f370329fc4f8a20eb57 /clang/test
parent7dc67a16a4b2f782ae1541f711663f17d6e92c05 (diff)
downloadbcm5719-llvm-916ac4d23323f2d08006bb58e7f61d0feade998a.tar.gz
bcm5719-llvm-916ac4d23323f2d08006bb58e7f61d0feade998a.zip
ms-compat: Fix taking the address of a member of a dependent base
If unqualified id lookup fails while parsing a class template with a dependent base, clang with -fms-compatibility will pretend the user prefixed the name with 'this->' in order to delay the lookup. However, if there was a unary ampersand, Sema::ActOnDependentIdExpression() will create a DependentDeclRefExpr, which is not what we wanted at all. Fix this by building the CXXDependentScopeMemberExpr directly instead. In order to be fully MSVC compatible, we would have to defer all attempts at name lookup to instantiation time. However, until we have real problems with system headers that can't be parsed, we'll put off implementing that. Fixes PR16014. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1892 llvm-svn: 192727
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
index cb1a7f50b71..72ce056063e 100644
--- a/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ b/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -196,3 +196,43 @@ void f() {
}
} // namespace PR12701
+
+namespace PR16014 {
+
+struct A {
+ int a;
+ static int sa;
+};
+template <typename T> struct B : T {
+ int foo() { return a; }
+ int *bar() { return &a; }
+ int baz() { return T::a; }
+ int T::*qux() { return &T::a; }
+ static int T::*stuff() { return &T::a; }
+ static int stuff1() { return T::sa; }
+ static int *stuff2() { return &T::sa; }
+};
+
+template <typename T> struct C : T {
+ int foo() { return b; } // expected-error {{no member named 'b' in 'PR16014::C<PR16014::A>'}}
+ int *bar() { return &b; } // expected-error {{no member named 'b' in 'PR16014::C<PR16014::A>'}}
+ int baz() { return T::b; } // expected-error {{no member named 'b' in 'PR16014::A'}}
+ int T::*qux() { return &T::b; } // expected-error {{no member named 'b' in 'PR16014::A'}}
+ int T::*fuz() { return &U::a; } // expected-error {{use of undeclared identifier 'U'}}
+};
+
+template struct B<A>;
+template struct C<A>; // expected-note-re 1+ {{in instantiation of member function 'PR16014::C<PR16014::A>::.*' requested here}}
+
+template <typename T> struct D : T {
+ struct Inner {
+ int foo() {
+ // FIXME: MSVC can find this in D's base T! Even worse, if ::sa exists,
+ // clang will use it instead.
+ return sa; // expected-error {{use of undeclared identifier 'sa'}}
+ }
+ };
+};
+template struct D<A>;
+
+}
OpenPOWER on IntegriCloud