Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 2 | |
| 3 | template<typename T> class A; |
| 4 | |
| 5 | extern "C++" { |
| 6 | template<typename T> class B; |
| 7 | } |
| 8 | |
| 9 | namespace N { |
| 10 | template<typename T> class C; |
| 11 | } |
| 12 | |
| 13 | extern "C" { |
| 14 | template<typename T> class D; // expected-error{{templates must have C++ linkage}} |
| 15 | } |
| 16 | |
Douglas Gregor | ed4ec8f | 2009-05-03 17:18:57 +0000 | [diff] [blame] | 17 | template<class U> class A; // expected-note{{previous template declaration is here}} |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 18 | |
| 19 | template<int N> class A; // expected-error{{template parameter has a different kind in template redeclaration}} |
| 20 | |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 21 | template<int N> class NonTypeTemplateParm; |
| 22 | |
| 23 | typedef int INT; |
| 24 | |
Chris Lattner | d0344a4 | 2009-02-19 23:45:49 +0000 | [diff] [blame] | 25 | template<INT M> class NonTypeTemplateParm; // expected-note{{previous non-type template parameter with type 'INT' (aka 'int') is here}} |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 26 | |
| 27 | template<long> class NonTypeTemplateParm; // expected-error{{template non-type parameter has a different type 'long' in template redeclaration}} |
| 28 | |
| 29 | template<template<typename T> class X> class TemplateTemplateParm; |
| 30 | |
| 31 | template<template<class> class Y> class TemplateTemplateParm; // expected-note{{previous template declaration is here}} \ |
| 32 | // expected-note{{previous template template parameter is here}} |
| 33 | |
| 34 | template<typename> class TemplateTemplateParm; // expected-error{{template parameter has a different kind in template redeclaration}} |
| 35 | |
| 36 | template<template<typename T, int> class X> class TemplateTemplateParm; // expected-error{{too many template parameters in template template parameter redeclaration}} |
| 37 | |
Douglas Gregor | 4c4f7cb | 2009-06-22 23:20:33 +0000 | [diff] [blame] | 38 | template<typename T> |
| 39 | struct test {}; // expected-note{{previous definition}} |
| 40 | |
| 41 | template<typename T> |
| 42 | struct test : T {}; // expected-error{{redefinition}} |
| 43 | |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 44 | class X { |
| 45 | public: |
| 46 | template<typename T> class C; |
| 47 | }; |
| 48 | |
| 49 | void f() { |
Douglas Gregor | c2f3882 | 2009-11-05 20:02:41 +0000 | [diff] [blame] | 50 | template<typename T> class X; // expected-error{{expression}} |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 51 | } |
Douglas Gregor | c7621a6 | 2009-11-05 20:54:04 +0000 | [diff] [blame] | 52 | |
Richard Smith | cf6b0a2 | 2011-07-14 21:35:26 +0000 | [diff] [blame] | 53 | template<typename T> class X1 var; // expected-error{{declared as a template}} |
Douglas Gregor | 57265e3 | 2010-04-12 16:00:01 +0000 | [diff] [blame] | 54 | |
| 55 | namespace M { |
| 56 | } |
| 57 | |
| 58 | template<typename T> class M::C3 { }; // expected-error{{out-of-line definition of 'C3' does not match any declaration in namespace 'M'}} |
Nick Lewycky | 37574f5 | 2010-11-08 23:29:42 +0000 | [diff] [blame] | 59 | |
| 60 | namespace PR8001 { |
| 61 | template<typename T1> |
| 62 | struct Foo { |
| 63 | template<typename T2> class Bar; |
| 64 | typedef Bar<T1> Baz; |
| 65 | |
| 66 | template<typename T2> |
| 67 | struct Bar { |
| 68 | Bar() {} |
| 69 | }; |
| 70 | }; |
| 71 | |
| 72 | void pr8001() { |
| 73 | Foo<int>::Baz x; |
| 74 | Foo<int>::Bar<int> y(x); |
| 75 | } |
| 76 | } |
Douglas Gregor | 95e5510 | 2011-10-21 15:47:52 +0000 | [diff] [blame] | 77 | |
Douglas Gregor | 2c1227c | 2011-11-07 17:43:18 +0000 | [diff] [blame] | 78 | namespace rdar9676205 { |
| 79 | template <unsigned, class _Tp> class tuple_element; |
| 80 | |
| 81 | template <class _T1, class _T2> class pair; |
| 82 | |
| 83 | template <class _T1, class _T2> |
| 84 | class tuple_element<0, pair<_T1, _T2> > |
| 85 | { |
| 86 | template <class _Tp> |
| 87 | struct X |
| 88 | { |
| 89 | template <class _Up, bool = X<_Up>::value> |
| 90 | struct Y |
| 91 | : public X<_Up>, |
| 92 | public Y<_Up> |
| 93 | { }; |
| 94 | }; |
| 95 | }; |
| 96 | } |
| 97 | |