// { dg-do compile } // Templates defined outside must be declared inside namespace bar { // trick it to provide some prior declaration template void foo(); // { dg-error "definition" } templateclass X; // { dg-message "note: previous declaration" } } template T const bar::foo(T const &a) // { dg-error "" "" { xfail *-*-* } } not declared in bar - { return a; } template<> void bar::foo() // { dg-error "different namespace" } { } template class bar::X{}; // { dg-error "redeclared with 2 template parameter" }