blob: 8314688bcbc7e688a5e040c880e64193e8dd9731 [file] [log] [blame]
Richard Smithb1ce9292013-06-22 22:03:31 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
Anders Carlsson0dde18e2009-08-28 15:18:15 +00002
3template<typename T> struct A {
4 void f() { }
John McCall7ba107a2009-11-18 02:36:19 +00005 struct N { }; // expected-note{{target of using declaration}}
Anders Carlsson0dde18e2009-08-28 15:18:15 +00006};
7
8template<typename T> struct B : A<T> {
9 using A<T>::f;
John McCall7ba107a2009-11-18 02:36:19 +000010 using A<T>::N; // expected-error{{dependent using declaration resolved to type without 'typename'}}
Anders Carlsson0dde18e2009-08-28 15:18:15 +000011
12 using A<T>::foo; // expected-error{{no member named 'foo'}}
John McCall604e7f12009-12-08 07:46:18 +000013 using A<double>::f; // expected-error{{using declaration refers into 'A<double>::', which is not a base class of 'B<int>'}}
Anders Carlsson0dde18e2009-08-28 15:18:15 +000014};
15
John McCall7c2342d2010-03-10 11:27:22 +000016B<int> a; // expected-note{{in instantiation of template class 'B<int>' requested here}}
Anders Carlsson36ef0782009-08-28 17:57:07 +000017
18template<typename T> struct C : A<T> {
19 using A<T>::f;
20
21 void f() { };
22};
Anders Carlsson203cb712009-08-29 00:56:38 +000023
24template <typename T> struct D : A<T> {
25 using A<T>::f;
26
27 void f();
28};
29
30template<typename T> void D<T>::f() { }
Anders Carlsson598da5b2009-08-29 01:06:32 +000031
32template<typename T> struct E : A<T> {
33 using A<T>::f;
34
35 void g() { f(); }
36};
John McCalled976492009-12-04 22:46:56 +000037
38namespace test0 {
39 struct Base {
40 int foo;
41 };
42 template<typename T> struct E : Base {
43 using Base::foo;
44 };
45
46 template struct E<int>;
47}
Argyrios Kyrtzidisc80117e2010-11-04 08:48:52 +000048
49// PR7896
50namespace PR7896 {
51template <class T> struct Foo {
52 int k (float);
53};
54struct Baz {
55 int k (int);
56};
57template <class T> struct Bar : public Foo<T>, Baz {
58 using Foo<T>::k;
59 using Baz::k;
60 int foo() {
61 return k (1.0f);
62 }
63};
64template int Bar<int>::foo();
65}
Kaelyn Uhrain82340e82011-09-07 20:25:59 +000066
67// PR10883
68namespace PR10883 {
69 template <typename T>
70 class Base {
71 public:
72 typedef long Container;
73 };
74
75 template <typename T>
76 class Derived : public Base<T> {
77 public:
78 using Base<T>::Container;
79
80 void foo(const Container& current); // expected-error {{unknown type name 'Container'}}
81 };
82}
Eli Friedman89643672013-06-20 00:04:23 +000083
84template<typename T> class UsingTypenameNNS {
85 using typename T::X;
86 typename X::X x;
87};
Richard Smithb1ce9292013-06-22 22:03:31 +000088
89namespace aliastemplateinst {
90 template<typename T> struct A { };
91 template<typename T> using APtr = A<T*>; // expected-note{{previous use is here}}
92
93 template struct APtr<int>; // expected-error{{elaborated type refers to a non-tag type}}
94}