1 // { dg-do compile } 2 // Templates defined outside must be declared inside 3 namespace bar 4 { 5 // trick it to provide some prior declaration 6 template<class T> 7 void foo(); // { dg-error "definition" } 8 template<class T>class X; // { dg-message "note: previous declaration" } 9 } 10 11 template <typename T> 12 T const foo(T const & a)13bar::foo(T const &a) // { dg-error "" "" { xfail *-*-* } } not declared in bar - 14 { 15 return a; 16 } 17 18 template<> void bar::foo<int>() // { dg-error "different namespace" } 19 { 20 } 21 22 template<class T,class U> 23 class bar::X{}; // { dg-error "redeclared with 2 template parameter" } 24