diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp')
-rw-r--r-- | clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp | 145 |
1 files changed, 145 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 new file mode 100644 index 0000000..2c422dc --- /dev/null +++ b/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -0,0 +1,145 @@ +// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s + + +template <class T> +class A { +public: + void f(T a) { }// expected-note {{must qualify identifier to find this declaration in dependent base class}} + void g();// expected-note {{must qualify identifier to find this declaration in dependent base class}} +}; + + +template <class T> +class B : public A<T> { +public: + void z(T a) + { + f(a); // expected-warning {{use of identifier 'f' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + } +}; + +template class B<int>; // expected-note {{requested here}} +template class B<char>; + +void test() +{ + B<int> b; + b.z(3); +} + +namespace lookup_dependent_bases_id_expr { + +template<class T> class A { +public: + int var; +}; + + +template<class T> +class B : public A<T> { +public: + void f() { + var = 3; + } +}; + +template class B<int>; + +} + + + +namespace lookup_dependent_base_class_static_function { + +template <class T> +class A { +public: + static void static_func();// expected-note {{must qualify identifier to find this declaration in dependent base class}} + void func();// expected-note {{must qualify identifier to find this declaration in dependent base class}} +}; + + +template <class T> +class B : public A<T> { +public: + static void z2(){ + static_func(); // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + func(); // expected-warning {{use of identifier 'func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}} + } +}; +template class B<int>; // expected-note {{requested here}} + +} + + + +namespace lookup_dependent_base_class_default_argument { + +template<class T> +class A { +public: + static int f1(); // expected-note {{must qualify identifier to find this declaration in dependent base class}} + int f2(); // expected-note {{must qualify identifier to find this declaration in dependent base class}} +}; + +template<class T> +class B : public A<T> { +public: + void g1(int p = f1());// expected-warning {{use of identifier 'f1' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + void g2(int p = f2());// expected-warning {{use of identifier 'f2' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}} +}; + +void foo() +{ + B<int> b; + b.g1(); // expected-note {{required here}} + b.g2(); // expected-note {{required here}} +} + +} + + +namespace lookup_dependent_base_class_friend { + +template <class T> +class B { +public: + static void g(); // expected-note {{must qualify identifier to find this declaration in dependent base class}} +}; + +template <class T> +class A : public B<T> { +public: + friend void foo(A<T> p){ + g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + } +}; + +int main2() +{ + A<int> a; + foo(a); // expected-note {{requested here}} +} + +} + + +namespace lookup_dependent_base_no_typo_correction { + +class C { +public: + int m_hWnd; +}; + +template <class T> +class A : public T { +public: + void f(int hWnd) { + m_hWnd = 1; + } +}; + +template class A<C>; + +} |