[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / clang / test / SemaTemplate / class-template-decl.cpp
blobdd9dcd2de9f4c91c6922e817a42e82cae92102cc
1 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
3 template<typename T> class A;
5 extern "C++" {
6 template<typename T> class B;
9 namespace N {
10 template<typename T> class C;
13 extern "C" { // expected-note {{extern "C" language linkage specification begins here}}
14 template<typename T> class D; // expected-error{{templates must have C++ linkage}}
17 extern "C" { // expected-note 2 {{extern "C" language linkage specification begins here}}
18 class PR17968 {
19 template<typename T> class D; // expected-error{{templates must have C++ linkage}}
20 template<typename T> void f(); // expected-error{{templates must have C++ linkage}}
24 template<class U> class A; // expected-note{{previous template declaration is here}}
26 template<int N> class A; // expected-error{{template parameter has a different kind in template redeclaration}}
28 template<int N> class NonTypeTemplateParm;
30 typedef int INT;
32 template<INT M> class NonTypeTemplateParm; // expected-note{{previous non-type template parameter with type 'INT' (aka 'int') is here}}
34 template<long> class NonTypeTemplateParm; // expected-error{{template non-type parameter has a different type 'long' in template redeclaration}}
36 template<template<typename T> class X> class TemplateTemplateParm;
38 template<template<class> class Y> class TemplateTemplateParm; // expected-note{{previous template declaration is here}} \
39 // expected-note{{previous template template parameter is here}}
41 template<typename> class TemplateTemplateParm; // expected-error{{template parameter has a different kind in template redeclaration}}
43 template<template<typename T, int> class X> class TemplateTemplateParm; // expected-error{{too many template parameters in template template parameter redeclaration}}
45 template<typename T>
46 struct test {}; // expected-note{{previous definition}}
48 template<typename T>
49 struct test : T {}; // expected-error{{redefinition}}
51 class X {
52 public:
53 template<typename T> class C;
56 void f() {
57 template<typename T> class X; // expected-error{{expression}}
60 template<typename T> class X1 var; // expected-error {{variable has incomplete type 'class X1'}} \
61 // expected-note {{forward declaration of 'X1'}}
63 namespace M {
66 template<typename T> class M::C3 { }; // expected-error{{out-of-line definition of 'C3' does not match any declaration in namespace 'M'}}
68 namespace PR8001 {
69 template<typename T1>
70 struct Foo {
71 template<typename T2> class Bar;
72 typedef Bar<T1> Baz;
74 template<typename T2>
75 struct Bar {
76 Bar() {}
80 void pr8001() {
81 Foo<int>::Baz x;
82 Foo<int>::Bar<int> y(x);
86 namespace rdar9676205 {
87 template <unsigned, class _Tp> class tuple_element;
89 template <class _T1, class _T2> class pair;
91 template <class _T1, class _T2>
92 class tuple_element<0, pair<_T1, _T2> >
94 template <class _Tp>
95 struct X
97 template <class _Up, bool = X<_Up>::value>
98 struct Y
99 : public X<_Up>,
100 public Y<_Up>
101 { };
106 namespace redecl {
107 int A; // expected-note {{here}}
108 template<typename T> struct A; // expected-error {{different kind of symbol}}
110 int B; // expected-note {{here}}
111 template<typename T> struct B { // expected-error {{different kind of symbol}}
114 template<typename T> struct F;
115 template<typename T> struct K;
117 int G, H; // expected-note {{here}}
119 struct S {
120 int C; // expected-note {{here}}
121 template<typename T> struct C; // expected-error {{different kind of symbol}}
123 int D; // expected-note {{here}}
124 template<typename T> struct D { // expected-error {{different kind of symbol}}
127 int E;
128 template<typename T> friend struct E { // expected-error {{cannot define a type in a friend}}
131 int F;
132 template<typename T> friend struct F; // ok, redecl::F
134 template<typename T> struct G; // ok
136 template<typename T> friend struct H; // expected-error {{different kind of symbol}}
138 int I, J, K;
140 struct U {
141 template<typename T> struct I; // ok
142 template<typename T> struct J { // ok
144 template<typename T> friend struct K; // ok, redecl::K
149 extern "C" template <typename T> // expected-error{{templates must have C++ linkage}}
150 void DontCrashOnThis() { // expected-note@-1 {{extern "C" language linkage specification begins here}}
151 T &pT = T();
155 namespace abstract_dependent_class {
156 template<typename T> struct A {
157 virtual A<T> *clone() = 0; // expected-note {{pure virtual}}
159 template<typename T> A<T> *A<T>::clone() { return new A<T>; } // expected-error {{abstract class type 'A<T>'}}