[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaTemplate / nested-template.cpp
blobefbde2076b9fa1a3135eae09412ab54f51b866be
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 class A;
4 class S {
5 public:
6 template<typename T> struct A {
7 struct Nested {
8 typedef T type;
9 };
13 int i;
14 S::A<int>::Nested::type *ip = &i;
16 template<typename T>
17 struct Outer {
18 template<typename U>
19 class Inner0;
21 template<typename U>
22 class Inner1 {
23 struct ReallyInner;
25 T foo(U);
26 template<typename V> T bar(V);
27 template<typename V> T* bar(V);
29 static T value1;
30 static U value2;
34 template<typename X>
35 template<typename Y>
36 class Outer<X>::Inner0 {
37 public:
38 void f(X, Y);
41 template<typename X>
42 template<typename Y>
43 void Outer<X>::Inner0<Y>::f(X, Y) {
46 template<typename X>
47 template<typename Y>
48 struct Outer<X>::Inner1<Y>::ReallyInner {
49 static Y value3;
51 void g(X, Y);
54 template<typename X>
55 template<typename Y>
56 void Outer<X>::Inner1<Y>::ReallyInner::g(X, Y) {
59 template<typename X>
60 template<typename Y>
61 X Outer<X>::Inner1<Y>::foo(Y) {
62 return X();
65 template<typename X>
66 template<typename Y>
67 template<typename Z>
68 X Outer<X>::Inner1<Y>::bar(Z) {
69 return X();
72 template<typename X>
73 template<typename Y>
74 template<typename Z>
75 X* Outer<X>::Inner1<Y>::bar(Z) {
76 return 0;
79 template<typename X>
80 template<typename Y>
81 X Outer<X>::Inner1<Y>::value1 = 0;
83 template<typename X>
84 template<typename Y>
85 Y Outer<X>::Inner1<Y>::value2 = Y();
87 template<typename X>
88 template<typename Y>
89 Y Outer<X>::Inner1<Y>::ReallyInner::value3 = Y();
91 template<typename X>
92 template<typename Y>
93 Y Outer<X>::Inner1<Y*>::ReallyInner::value4; // expected-error{{Outer<X>::Inner1<Y *>::ReallyInner::}}
96 template<typename T>
97 struct X0 { };
99 template<typename T>
100 struct X0<T*> {
101 template<typename U>
102 void f(U u = T()) { }
105 // PR5103
106 template<typename>
107 struct X1 {
108 template<typename, bool = false> struct B { };
110 template struct X1<int>::B<bool>;
112 // Template template parameters
113 template<typename T>
114 struct X2 {
115 template<template<class U, T Value> class> // expected-error{{cannot have type 'float'}} \
116 // expected-note{{previous non-type template}}
117 struct Inner { };
120 template<typename T,
121 int Value> // expected-note{{template non-type parameter}}
122 struct X2_arg;
124 X2<int>::Inner<X2_arg> x2i1;
125 X2<float> x2a; // expected-note{{instantiation}}
126 X2<long>::Inner<X2_arg> x2i3; // expected-error{{template template argument has different}}
128 namespace PR10896 {
129 template<typename TN>
130 class Foo {
132 public:
133 void foo() {}
134 private:
136 template<typename T>
137 T SomeField; // expected-error {{member 'SomeField' declared as a template}}
138 template<> int SomeField2; // expected-error {{extraneous 'template<>' in declaration of member 'SomeField2'}}
141 void g() {
142 Foo<int> f;
143 f.foo();
147 namespace PR10924 {
148 template< class Topology, class ctype >
149 struct ReferenceElement
153 template< class Topology, class ctype >
154 template< int codim >
155 class ReferenceElement< Topology, ctype > :: BaryCenterArray // expected-error{{out-of-line definition of 'BaryCenterArray' does not match any declaration in 'ReferenceElement<Topology, ctype>'}}
160 class Outer1 {
161 template <typename T> struct X;
162 template <typename T> int X<T>::func() {} // expected-error{{out-of-line definition of 'func' from class 'X<T>' without definition}}
165 namespace RefPack {
166 template<const int &...N> struct A { template<typename ...T> void f(T (&...t)[N]); };
167 constexpr int k = 10;
168 int arr[10];
169 void g() { A<k>().f(arr); }