diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-06 22:42:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-06 22:42:48 +0000 |
commit | ddc29e116db3c3f4144355e67a0137b38b6bb6d1 (patch) | |
tree | add7fd5470501bcc7a612dac9fbd03b5918b86da /test/SemaTemplate/class-template-decl.cpp | |
parent | 4398a78095cd05a3be702fbab25bfe324a5d7946 (diff) |
Semantic checking for class template declarations and
redeclarations. For example, checks that a class template
redeclaration has the same template parameters as previous
declarations.
Detangled class-template checking from ActOnTag, whose logic was
getting rather convoluted because it tried to handle C, C++, and C++
template semantics in one shot.
Made some inroads toward eliminating extraneous "declaration does not
declare anything" errors by adding an "error" type specifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/class-template-decl.cpp')
-rw-r--r-- | test/SemaTemplate/class-template-decl.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/SemaTemplate/class-template-decl.cpp b/test/SemaTemplate/class-template-decl.cpp new file mode 100644 index 0000000000..3978e1f04a --- /dev/null +++ b/test/SemaTemplate/class-template-decl.cpp @@ -0,0 +1,52 @@ +// RUN: clang -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}}\ + // expected-note{{previous use is here}} + +template<int N> class A; // expected-error{{template parameter has a different kind in template redeclaration}} + +template<class T> struct A; // expected-error{{use of 'A' with tag type that does not match previous declaration}} + +template<int N> class NonTypeTemplateParm; + +typedef int INT; + +template<INT M> class NonTypeTemplateParm; // expected-note{{previous non-type template parameter with type '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}} + +#if 0 +// FIXME: parse template declarations in these scopes, so that we can +// complain about the one at function scope. +class X { +public: + template<typename T> class C; +}; + +void f() { + template<typename T> class X; +} +#endif |