// RUN: clang-cc -fsyntax-only -verify %s template struct A; // expected-note 2{{template is declared here}} 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{{incomplete definition of type 'A'}} (void)a2->x; // expected-error{{implicit instantiation of undefined template 'struct 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() { } // Diagnose specialization errors struct A { }; // expected-error{{template specialization requires 'template<>'}} template<> struct ::A; namespace N { template struct B; // expected-note 2{{template is declared here}} 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-error{{class template specialization of 'B' not in namespace 'N'}} namespace M { template<> struct ::N::B { }; // expected-error{{class template specialization of 'B' not in a namespace enclosing 'N'}} template<> struct ::A; // expected-error{{class template specialization of 'A' must occur in the global scope}} } template<> struct N::B { int testf(int x) { return f(x); } };