1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify %s
5 // C++03 [namespace.udecl]p12:
6 // When a using-declaration brings names from a base class into a
7 // derived class scope, member functions in the derived class
8 // override and/or hide member functions with the same name and
9 // parameter types in a base class (rather than conflicting).
11 template <unsigned n
> struct Opaque
{};
12 template <unsigned n
> void expect(Opaque
<n
> _
) {} // expected-note 4 {{candidate function template not viable}}
15 // This just shouldn't crash.
17 template<typename
> struct RefPtr
{ };
18 template<typename
> struct PtrHash
{
21 template<typename T
> struct PtrHash
<RefPtr
<T
> > : PtrHash
<T
*> {
23 static void f() { f(); }
30 Opaque
<0> foo(Opaque
<0>);
31 Opaque
<0> foo(Opaque
<1>);
32 Opaque
<0> foo(Opaque
<2>);
38 Opaque
<1> foo(Opaque
<1>);
39 Opaque
<1> foo(Opaque
<3>);
41 void test0() { Opaque
<0> _
= foo(Opaque
<0>()); }
42 void test1() { Opaque
<1> _
= foo(Opaque
<1>()); }
43 void test2() { Opaque
<0> _
= foo(Opaque
<2>()); }
44 void test3() { Opaque
<1> _
= foo(Opaque
<3>()); }
49 Opaque
<1> foo(Opaque
<1>);
50 Opaque
<1> foo(Opaque
<3>);
53 void test0() { Opaque
<0> _
= foo(Opaque
<0>()); }
54 void test1() { Opaque
<1> _
= foo(Opaque
<1>()); }
55 void test2() { Opaque
<0> _
= foo(Opaque
<2>()); }
56 void test3() { Opaque
<1> _
= foo(Opaque
<3>()); }
59 // using between decls
61 Opaque
<1> foo(Opaque
<0>);
63 Opaque
<1> foo(Opaque
<2>);
64 Opaque
<1> foo(Opaque
<3>);
66 void test0() { Opaque
<1> _
= foo(Opaque
<0>()); }
67 void test1() { Opaque
<0> _
= foo(Opaque
<1>()); }
68 void test2() { Opaque
<1> _
= foo(Opaque
<2>()); }
69 void test3() { Opaque
<1> _
= foo(Opaque
<3>()); }
73 // Crazy dependent hiding.
79 template <typename T
> struct Derived1
: Base
{
83 void testUnresolved(int i
) { foo(i
); }
92 // Same thing, except with the order of members reversed.
93 template <typename T
> struct Derived2
: Base
{
97 void testUnresolved(int i
) { foo(i
); }
103 d2
.testUnresolved(i
);
107 // Hiding of member templates.
110 template <class T
> Opaque
<0> foo() { return Opaque
<0>(); }
111 template <int n
> Opaque
<1> foo() { return Opaque
<1>(); }
114 struct Derived1
: Base
{
116 template <int n
> Opaque
<2> foo() { return Opaque
<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
119 struct Derived2
: Base
{
120 template <int n
> Opaque
<2> foo() { return Opaque
<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
124 struct Derived3
: Base
{
126 template <class T
> Opaque
<3> foo() { return Opaque
<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
129 struct Derived4
: Base
{
130 template <class T
> Opaque
<3> foo() { return Opaque
<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
135 expect
<0>(Base().foo
<int>());
136 expect
<1>(Base().foo
<0>());
137 expect
<0>(Derived1().foo
<int>()); // expected-error {{no matching member function for call to 'foo'}} expected-error {{no matching function for call to 'expect'}}
138 expect
<2>(Derived1().foo
<0>());
139 expect
<0>(Derived2().foo
<int>()); // expected-error {{no matching member function for call to 'foo'}} expected-error {{no matching function for call to 'expect'}}
140 expect
<2>(Derived2().foo
<0>());
141 expect
<3>(Derived3().foo
<int>());
142 expect
<1>(Derived3().foo
<0>()); // expected-error {{no matching member function for call to 'foo'}} expected-error {{no matching function for call to 'expect'}}
143 expect
<3>(Derived4().foo
<int>());
144 expect
<1>(Derived4().foo
<0>()); // expected-error {{no matching member function for call to 'foo'}} expected-error {{no matching function for call to 'expect'}}
148 // PR7384: access control for member templates.
152 template<typename T
> void foo(T
);
153 template<typename T
> void bar(T
); // expected-note {{declared protected here}}
156 struct Derived
: Base
{
163 d
.bar
<int>(3); // expected-error {{'bar' is a protected member}}
170 void operator=(const Derived
&);
172 struct Derived
: Base
{
173 // Hidden by implicit derived class operator.
174 using Base::operator=;
181 #if __cplusplus >= 201103L
185 void operator=(Derived
&&);
187 struct Derived
: Base
{
188 // Hidden by implicit derived class operator.
189 using Base::operator=;