diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaTemplate/class-template-decl.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaTemplate/class-template-decl.cpp')
-rw-r--r-- | clang/test/SemaTemplate/class-template-decl.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/class-template-decl.cpp b/clang/test/SemaTemplate/class-template-decl.cpp new file mode 100644 index 0000000..ec4e016 --- /dev/null +++ b/clang/test/SemaTemplate/class-template-decl.cpp @@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template<typename T> class A; + +extern "C++" { + template<typename T> class B; +} + +namespace N { + template<typename T> class C; +} + +extern "C" { + template<typename T> class D; // expected-error{{templates must have C++ linkage}} +} + +template<class U> class A; // expected-note{{previous template declaration is here}} + +template<int N> class A; // expected-error{{template parameter has a different kind in template redeclaration}} + +template<int N> class NonTypeTemplateParm; + +typedef int INT; + +template<INT M> class NonTypeTemplateParm; // expected-note{{previous non-type template parameter with type 'INT' (aka 'int') is here}} + +template<long> class NonTypeTemplateParm; // expected-error{{template non-type parameter has a different type 'long' in template redeclaration}} + +template<template<typename T> class X> class TemplateTemplateParm; + +template<template<class> class Y> class TemplateTemplateParm; // expected-note{{previous template declaration is here}} \ + // expected-note{{previous template template parameter is here}} + +template<typename> class TemplateTemplateParm; // expected-error{{template parameter has a different kind in template redeclaration}} + +template<template<typename T, int> class X> class TemplateTemplateParm; // expected-error{{too many template parameters in template template parameter redeclaration}} + +template<typename T> +struct test {}; // expected-note{{previous definition}} + +template<typename T> +struct test : T {}; // expected-error{{redefinition}} + +class X { +public: + template<typename T> class C; +}; + +void f() { + template<typename T> class X; // expected-error{{expression}} +} + +template<typename T> class X1 var; // expected-error{{declared as a template}} + +namespace M { +} + +template<typename T> class M::C3 { }; // expected-error{{out-of-line definition of 'C3' does not match any declaration in namespace 'M'}} + +namespace PR8001 { + template<typename T1> + struct Foo { + template<typename T2> class Bar; + typedef Bar<T1> Baz; + + template<typename T2> + struct Bar { + Bar() {} + }; + }; + + void pr8001() { + Foo<int>::Baz x; + Foo<int>::Bar<int> y(x); + } +} + +namespace rdar9676205 { + template <unsigned, class _Tp> class tuple_element; + + template <class _T1, class _T2> class pair; + + template <class _T1, class _T2> + class tuple_element<0, pair<_T1, _T2> > + { + template <class _Tp> + struct X + { + template <class _Up, bool = X<_Up>::value> + struct Y + : public X<_Up>, + public Y<_Up> + { }; + }; + }; +} + |