// RUN: %clang_cc1 -fsyntax-only -verify %s template struct A; // expected-note {{template is declared here}} \ // expected-note{{explicitly specialized}} template<> struct A; // expected-note{{forward declaration}} template<> struct A { // expected-note{{previous definition}} int x; }; template<> struct A { // expected-note{{previous definition}} int y; }; int test_specs(A *a1, A *a2) { return a1->x + a2->y; } int test_incomplete_specs(A *a1, A *a2) { (void)a1->x; // expected-error{{member access into incomplete type}} (void)a2->x; // expected-error{{implicit instantiation of undefined template 'A'}} } typedef float FLOAT; template<> struct A; template<> struct A { }; // expected-error{{redefinition}} template<> struct A { }; // expected-error{{redefinition}} template struct X; template <> struct X { int foo(); }; // #1 template <> struct X { int bar(); }; // #2 typedef int int_type; void testme(X *x1, X *x2) { (void)x1->foo(); // okay: refers to #1 (void)x2->bar(); // okay: refers to #2 } // Make sure specializations are proper classes. template<> struct A { A(); }; A::A() { } // Make sure we can see specializations defined before the primary template. namespace N{ template struct A0; } namespace N { template<> struct A0 { typedef void* pointer; }; } namespace N { template struct A0 { void foo(A0::pointer p = 0); }; } // Diagnose specialization errors struct A { }; // expected-error{{template specialization requires 'template<>'}} template<> struct ::A; namespace N { template struct B; // expected-note 2{{explicitly specialized}} template<> struct ::N::B; // okay template<> struct ::N::B; // okay template<> struct ::N::B; // okay int f(int); } template<> struct N::B { }; // okay template<> struct N::B { }; // expected-warning{{C++11 extension}} namespace M { template<> struct ::N::B { }; // expected-error{{class template specialization of 'B' not in a namespace enclosing 'N'}} template<> struct ::A; // expected-error{{originally}} } template<> struct N::B { int testf(int x) { return f(x); } }; // PR5264 template class Foo; Foo* v; Foo& F() { return *v; } template class Foo {}; Foo x; // Template template parameters template class Wibble> class Wibble { }; // expected-error{{cannot specialize a template template parameter}} namespace rdar9676205 { template struct X { template struct X { // expected-error{{explicit specialization of 'X' in class scope}} }; }; }