diff options
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r-- | test/SemaTemplate/dependent-base-classes.cpp | 25 | ||||
-rw-r--r-- | test/SemaTemplate/destructor-template.cpp | 15 | ||||
-rw-r--r-- | test/SemaTemplate/explicit-specialization-member.cpp | 12 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-complete.cpp | 17 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-enum.cpp | 16 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-expr-1.cpp | 33 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-function-1.cpp | 6 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-init.cpp | 11 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-invalid.cpp | 52 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-static-var.cpp | 23 | ||||
-rw-r--r-- | test/SemaTemplate/member-access-expr.cpp | 2 | ||||
-rw-r--r-- | test/SemaTemplate/nested-name-spec-template.cpp | 1 | ||||
-rw-r--r-- | test/SemaTemplate/temp_arg.cpp | 7 | ||||
-rw-r--r-- | test/SemaTemplate/template-decl-fail.cpp | 5 | ||||
-rw-r--r-- | test/SemaTemplate/virtual-member-functions.cpp | 8 |
15 files changed, 225 insertions, 8 deletions
diff --git a/test/SemaTemplate/dependent-base-classes.cpp b/test/SemaTemplate/dependent-base-classes.cpp index 80d20b0..08d4de5 100644 --- a/test/SemaTemplate/dependent-base-classes.cpp +++ b/test/SemaTemplate/dependent-base-classes.cpp @@ -57,7 +57,6 @@ namespace PR6031 { int foo() { class NoDepBase::Nested nested; // expected-error{{'Nested' does not name a tag member in the specified scope}} typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{'MemberTemplate' following the 'template' keyword does not refer to a template}} \ - // FIXME: expected-error{{expected an identifier or template-id after '::'}} \ // FIXME: expected-error{{unqualified-id}} return NoDepBase::a; // expected-error{{no member named 'a' in 'struct PR6031::NoDepBase'}} } @@ -110,3 +109,27 @@ namespace PR6081 { } }; } + +namespace PR6413 { + template <typename T> class Base_A { }; + + class Base_B { }; + + template <typename T> + class Derived + : public virtual Base_A<T> + , public virtual Base_B + { }; +} + +namespace PR5812 { + template <class T> struct Base { + Base* p; + }; + + template <class T> struct Derived: public Base<T> { + typename Derived::Base* p; // meaning Derived::Base<T> + }; + + Derived<int> di; +} diff --git a/test/SemaTemplate/destructor-template.cpp b/test/SemaTemplate/destructor-template.cpp index b5ad967..83b1bee 100644 --- a/test/SemaTemplate/destructor-template.cpp +++ b/test/SemaTemplate/destructor-template.cpp @@ -17,3 +17,18 @@ void destroy_me(T me) { } template void destroy_me(Incomplete*); + +namespace PR6152 { + template<typename T> struct X { void f(); }; + template<typename T> struct Y { }; + template<typename T> + void X<T>::f() { + Y<T> *y; + y->template Y<T>::~Y(); + y->template Y<T>::~Y<T>(); + y->~Y(); + } + + template struct X<int>; +} + diff --git a/test/SemaTemplate/explicit-specialization-member.cpp b/test/SemaTemplate/explicit-specialization-member.cpp index 06dd382..cb0a39a 100644 --- a/test/SemaTemplate/explicit-specialization-member.cpp +++ b/test/SemaTemplate/explicit-specialization-member.cpp @@ -9,3 +9,15 @@ struct X0 { template<> void X0<char>::f0(char); template<> void X0<char>::f1(type); + +namespace PR6161 { + template<typename _CharT> + class numpunct : public locale::facet // expected-error{{use of undeclared identifier 'locale'}} \ + // expected-error{{expected class name}} \ + // expected-note{{attempt to specialize declaration here}} + { + static locale::id id; // expected-error{{use of undeclared identifier}} FIXME: expected-error {{unknown type name}} + }; + numpunct<char>::~numpunct(); // expected-error{{template specialization requires 'template<>'}} \ + // expected-error{{specialization of member 'PR6161::numpunct<char>::~numpunct' does not specialize an instantiated member}} +} diff --git a/test/SemaTemplate/instantiate-complete.cpp b/test/SemaTemplate/instantiate-complete.cpp index 183fefa..0ae13b9 100644 --- a/test/SemaTemplate/instantiate-complete.cpp +++ b/test/SemaTemplate/instantiate-complete.cpp @@ -66,3 +66,20 @@ struct X3 { void enum_constructors(X1<float> &x1) { X3<X1<float> > x3 = x1; } + +namespace PR6376 { + template<typename T, typename U> struct W { }; + + template<typename T> + struct X { + template<typename U> + struct apply { + typedef W<T, U> type; + }; + }; + + template<typename T, typename U> + struct Y : public X<T>::template apply<U>::type { }; + + template struct Y<int, float>; +} diff --git a/test/SemaTemplate/instantiate-enum.cpp b/test/SemaTemplate/instantiate-enum.cpp index 6f9aa4b..5353a92 100644 --- a/test/SemaTemplate/instantiate-enum.cpp +++ b/test/SemaTemplate/instantiate-enum.cpp @@ -9,3 +9,19 @@ struct adder { }; int array1[adder<long, 3, 4>::value == 7? 1 : -1]; + +namespace PR6375 { + template<typename T> + void f() { + enum Enum + { + enumerator1 = 0xFFFFFFF, + enumerator2 = enumerator1 - 1 + }; + + int xb1 = enumerator1; + int xe1 = enumerator2; + } + + template void f<int>(); +} diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp index d1b05f6..37145b6 100644 --- a/test/SemaTemplate/instantiate-expr-1.cpp +++ b/test/SemaTemplate/instantiate-expr-1.cpp @@ -137,3 +137,36 @@ void test_asm() { int b; test_asm(b); // expected-note {{in instantiation of function template specialization 'test_asm<int>' requested here}} } + +namespace PR6424 { + template<int I> struct X { + X() { + int *ip = I; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} + } + }; + + template<int> struct Y { + typedef X<7> X7; + + void f() { X7(); } // expected-note{{instantiation}} + }; + + template void Y<3>::f(); + + template<int I> + struct X2 { + void *operator new(__SIZE_TYPE__) { + int *ip = I; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} + return ip; + } + }; + + template<int> struct Y2 { + typedef X2<7> X; + void f() { + new X(); // expected-note{{instantiation of}} + } + }; + + template void Y2<3>::f(); +} diff --git a/test/SemaTemplate/instantiate-function-1.cpp b/test/SemaTemplate/instantiate-function-1.cpp index 543b3cc..144c630 100644 --- a/test/SemaTemplate/instantiate-function-1.cpp +++ b/test/SemaTemplate/instantiate-function-1.cpp @@ -177,9 +177,11 @@ template<typename T> struct IndirectGoto0 { goto *x; // expected-error{{incompatible}} prior: - T prior_label = &&prior; + T prior_label; + prior_label = &&prior; - T later_label = &&later; + T later_label; + later_label = &&later; later: (void)(1+1); diff --git a/test/SemaTemplate/instantiate-init.cpp b/test/SemaTemplate/instantiate-init.cpp index 8a10a87..16ecc47 100644 --- a/test/SemaTemplate/instantiate-init.cpp +++ b/test/SemaTemplate/instantiate-init.cpp @@ -26,3 +26,14 @@ void test_f1(X0 *x0, int *ip, float *fp, double *dp) { f1(x0, ip, dp); // expected-note{{instantiation}} } +namespace PR6457 { + template <typename T> struct X { explicit X(T* p = 0) { }; }; + template <typename T> struct Y { Y(int, const T& x); }; + struct A { }; + template <typename T> + struct B { + B() : y(0, X<A>()) { } + Y<X<A> > y; + }; + B<int> b; +} diff --git a/test/SemaTemplate/instantiate-invalid.cpp b/test/SemaTemplate/instantiate-invalid.cpp new file mode 100644 index 0000000..b8a5901 --- /dev/null +++ b/test/SemaTemplate/instantiate-invalid.cpp @@ -0,0 +1,52 @@ +// RUN: not %clang_cc1 -fsyntax-only %s +namespace PR6375 { + template<class Conv> class rasterizer_sl_clip Conv::xi(x2), Conv::yi(y2)); +namespace agg +{ + template<class Clip=rasterizer_sl_clip_int> class rasterizer_scanline_aa + { + template<class Scanline> bool sweep_scanline(Scanline& sl) + { + unsigned num_cells = m_outline.scanline_num_cells(m_scan_y); + while(num_cells) { } + } + } + class scanline_u8 {} + template<class PixelFormat> class renderer_base { } +} + template<class Rasterizer, class Scanline, class BaseRenderer, class ColorT> + void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, const ColorT& color) + { + while(ras.sweep_scanline(sl)) + { + } + }; +namespace agg +{ + struct rgba8 + { + }; + template<class Rasterizer, class Scanline, class Renderer, class Ctrl> + void render_ctrl(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c) + { + unsigned i; + render_scanlines_aa_solid(ras, sl, r, c.color(i)); + } + template<class ColorT> class rbox_ctrl : public rbox_ctrl_impl + { + const ColorT& color(unsigned i) const { return *m_colors[i]; } + } +class the_application : public agg::platform_support +{ + agg::rbox_ctrl<agg::rgba8> m_polygons; + virtual void on_init() + { + typedef agg::renderer_base<pixfmt_type> base_ren_type; + base_ren_type ren_base(pf); + agg::scanline_u8 sl; + agg::rasterizer_scanline_aa<> ras; + agg::render_ctrl(ras, sl, ren_base, m_polygons); + } +}; +} +} diff --git a/test/SemaTemplate/instantiate-static-var.cpp b/test/SemaTemplate/instantiate-static-var.cpp index 789fe3d..fda2b9ea 100644 --- a/test/SemaTemplate/instantiate-static-var.cpp +++ b/test/SemaTemplate/instantiate-static-var.cpp @@ -92,3 +92,26 @@ struct SizeOf { void MyTest3() { Y3().Foo(X3<SizeOf<char>::value>()); } + +namespace PR6449 { + template<typename T> + struct X0 { + static const bool var = false; + }; + + template<typename T> + const bool X0<T>::var; + + template<typename T> + struct X1 : public X0<T> { + static const bool var = false; + }; + + template<typename T> + const bool X1<T>::var; + + template class X0<char>; + template class X1<char>; + +} + diff --git a/test/SemaTemplate/member-access-expr.cpp b/test/SemaTemplate/member-access-expr.cpp index 116e837..24db791 100644 --- a/test/SemaTemplate/member-access-expr.cpp +++ b/test/SemaTemplate/member-access-expr.cpp @@ -63,11 +63,13 @@ void test_convert(X2 x2) { template<typename T> void destruct(T* ptr) { ptr->~T(); + ptr->T::~T(); } template<typename T> void destruct_intptr(int *ip) { ip->~T(); + ip->T::~T(); } void test_destruct(X2 *x2p, int *ip) { diff --git a/test/SemaTemplate/nested-name-spec-template.cpp b/test/SemaTemplate/nested-name-spec-template.cpp index 704b8cf..1691db7 100644 --- a/test/SemaTemplate/nested-name-spec-template.cpp +++ b/test/SemaTemplate/nested-name-spec-template.cpp @@ -49,6 +49,5 @@ struct ::N::A<int>::X { template<typename T> struct TestA { typedef typename N::template B<T>::type type; // expected-error{{'B' following the 'template' keyword does not refer to a template}} \ - // expected-error{{identifier or template-id}} \ // expected-error{{expected member name}} }; diff --git a/test/SemaTemplate/temp_arg.cpp b/test/SemaTemplate/temp_arg.cpp index 3c9fcb5..80bbda7 100644 --- a/test/SemaTemplate/temp_arg.cpp +++ b/test/SemaTemplate/temp_arg.cpp @@ -10,3 +10,10 @@ A<int, 0, X> * a1; A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}} A<float, 1> *a3; // expected-error{{too few template arguments for class template 'A'}} + +namespace test0 { + template <class t> class foo {}; + template <class t> class bar { + bar(::test0::foo<tee> *ptr) {} // FIXME(redundant): expected-error 2 {{use of undeclared identifier 'tee'}} + }; +} diff --git a/test/SemaTemplate/template-decl-fail.cpp b/test/SemaTemplate/template-decl-fail.cpp index a298c6d..eca0f58 100644 --- a/test/SemaTemplate/template-decl-fail.cpp +++ b/test/SemaTemplate/template-decl-fail.cpp @@ -1,3 +1,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s template<typename T> typedef T X; // expected-error{{typedef cannot be a template}} + +template<typename T> +enum t0 { A = T::x }; // expected-error{{enumeration cannot be a template}} \ + // expected-error{{declaration does not declare anything}} + diff --git a/test/SemaTemplate/virtual-member-functions.cpp b/test/SemaTemplate/virtual-member-functions.cpp index db24313..58ac08c 100644 --- a/test/SemaTemplate/virtual-member-functions.cpp +++ b/test/SemaTemplate/virtual-member-functions.cpp @@ -14,7 +14,7 @@ template<class T> int A<T>::a(T x) { } void f(A<int> x) { - x.anchor(); + x.anchor(); // expected-note{{in instantiation of member function 'PR5557::A<int>::anchor' requested here}} } template<typename T> @@ -36,10 +36,10 @@ struct Base { template<typename T> struct Derived : Base<T> { - virtual void foo() { } + virtual void foo() { } // expected-note {{in instantiation of member function 'Base<int>::~Base' requested here}} }; -template struct Derived<int>; // expected-note{{instantiation}} +template struct Derived<int>; template<typename T> struct HasOutOfLineKey { @@ -52,4 +52,4 @@ T *HasOutOfLineKey<T>::f(float *fp) { return fp; // expected-error{{cannot initialize return object of type 'int *' with an lvalue of type 'float *'}} } -HasOutOfLineKey<int> out_of_line; +HasOutOfLineKey<int> out_of_line; // expected-note{{in instantiation of member function 'HasOutOfLineKey<int>::HasOutOfLineKey' requested here}} |