From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaTemplate/explicit-instantiation.cpp | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 clang/test/SemaTemplate/explicit-instantiation.cpp (limited to 'clang/test/SemaTemplate/explicit-instantiation.cpp') diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp new file mode 100644 index 0000000..13d76be --- /dev/null +++ b/clang/test/SemaTemplate/explicit-instantiation.cpp @@ -0,0 +1,107 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template void *; // expected-error{{expected unqualified-id}} + +template typedef void f0; // expected-error{{explicit instantiation of typedef}} + +int v0; // expected-note{{refers here}} +template int v0; // expected-error{{does not refer}} + +template +struct X0 { + static T value; + + T f0(T x) { + return x + 1; // expected-error{{invalid operands}} + } + T* f0(T*, T*) { return T(); } + + template + T f0(T, U) { return T(); } +}; + +template +T X0::value; // expected-error{{no matching constructor}} + +template int X0::value; + +struct NotDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor)}} + NotDefaultConstructible(int); // expected-note{{candidate constructor}} +}; + +template NotDefaultConstructible X0::value; // expected-note{{instantiation}} + +template int X0::f0(int); +template int* X0::f0(int*, int*); +template int X0::f0(int, float); + +template int X0::f0(int) const; // expected-error{{does not refer}} +template int* X0::f0(int*, float*); // expected-error{{does not refer}} + +struct X1 { }; +typedef int X1::*MemPtr; + +template MemPtr X0::f0(MemPtr); // expected-note{{requested here}} + +struct X2 { + int f0(int); // expected-note{{refers here}} + + template T f1(T) { return T(); } + template T* f1(T*) { return 0; } + + template void f2(T, U*) { } // expected-note{{candidate}} + template void f2(T*, U) { } // expected-note{{candidate}} +}; + +template int X2::f0(int); // expected-error{{not an instantiation}} + +template int *X2::f1(int *); // okay + +template void X2::f2(int *, int *); // expected-error{{ambiguous}} + + +template void print_type() { } + +template void print_type(); +template void print_type(); + +template void print_type(T*) { } + +template void print_type(int*); +template void print_type(float*); // expected-error{{does not refer}} + +void print_type(double*); +template void print_type(double*); + +// PR5069 +template void foo0 (int (&)[I + 1]) { } +template void foo0<2> (int (&)[3]); + +namespace explicit_instantiation_after_implicit_instantiation { + template struct X0 { static int x; }; + template int X0::x; + void test1() { (void)&X0<1>::x; } + template struct X0<1>; +} + +template struct X3 { }; +inline template struct X3; // expected-warning{{ignoring 'inline' keyword on explicit template instantiation}} +static template struct X3; // expected-warning{{ignoring 'static' keyword on explicit template instantiation}} + +namespace PR7622 { + template + struct basic_streambuf; + + template + struct basic_streambuf{friend bob<>()}; // expected-error{{unknown type name 'bob'}} \ + // expected-error{{expected member name or ';' after declaration specifiers}} + template struct basic_streambuf; +} + +// Test that we do not crash. +class TC1 { + class TC2 { + template // FIXME: error here. + void foo() { } + }; +}; -- cgit v1.2.3