[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / using-decl-templates.cpp
blob73d9bc3e774cb6d255ae1075ae0d7dd8ecbc515d
1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
3 template<typename T> struct A {
4 void f() { }
5 struct N { }; // expected-note{{target of using declaration}}
6 };
8 template<typename T> struct B : A<T> {
9 using A<T>::f;
10 using A<T>::N; // expected-error{{dependent using declaration resolved to type without 'typename'}}
12 using A<T>::foo; // expected-error{{no member named 'foo'}}
13 using A<double>::f; // expected-error{{using declaration refers into 'A<double>::', which is not a base class of 'B<int>'}}
16 B<int> a; // expected-note{{in instantiation of template class 'B<int>' requested here}}
18 template<typename T> struct C : A<T> {
19 using A<T>::f;
21 void f() { };
24 template <typename T> struct D : A<T> {
25 using A<T>::f;
27 void f();
30 template<typename T> void D<T>::f() { }
32 template<typename T> struct E : A<T> {
33 using A<T>::f;
35 void g() { f(); }
38 namespace test0 {
39 struct Base {
40 int foo;
42 template<typename T> struct E : Base {
43 using Base::foo;
46 template struct E<int>;
49 // PR7896
50 namespace PR7896 {
51 template <class T> struct Foo {
52 int k (float);
54 struct Baz {
55 int k (int);
57 template <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);
64 template int Bar<int>::foo();
67 // PR10883
68 namespace PR10883 {
69 template <typename T>
70 class Base {
71 public:
72 typedef long Container;
75 template <typename T>
76 class Derived : public Base<T> {
77 public:
78 using Base<T>::Container;
80 void foo(const Container& current); // expected-error {{unknown type name 'Container'}}
84 template<typename T> class UsingTypenameNNS {
85 using typename T::X;
86 typename X::X x;
89 namespace aliastemplateinst {
90 template<typename T> struct A { };
91 template<typename T> using APtr = A<T*>; // expected-note{{previous use is here}}
93 template struct APtr<int>; // expected-error{{type alias template 'APtr' cannot be referenced with a struct specifier}}
96 namespace DontDiagnoseInvalidTest {
97 template <bool Value> struct Base {
98 static_assert(Value, ""); // expected-error {{static assertion failed}}
100 struct Derived : Base<false> { // expected-note {{requested here}}
101 using Base<false>::Base; // OK. Don't diagnose that 'Base' isn't a base class of Derived.
103 } // namespace DontDiagnoseInvalidTest
105 namespace func_templ {
106 namespace sss {
107 double foo(int, double);
108 template <class T>
109 T foo(T);
110 } // namespace sss
112 namespace oad {
113 void foo();
116 namespace oad {
117 using sss::foo;
120 namespace sss {
121 using oad::foo;
124 namespace sss {
125 double foo(int, double) { return 0; }
126 // There used to be an error with the below declaration when the example should
127 // be accepted.
128 template <class T>
129 T foo(T t) { // OK
130 return t;
132 } // namespace sss
133 } // namespace func_templ