If a template is declared in a scope, where it may not, do not mark it
as invalid declaration. Name lookup then can find the declaration, this
reduce number of diagnostic messages.
For instance, the code:
extern "C" {
namespace ns11416 {
template <class R> class Sphere_d;
template <class R> bool equal_as_sets(const Sphere_d<R>&, const Sphere_d<R>&);
}
}produces:
pr11416.cpp:3:5: error: templates must have C++ linkage
template <class R> class Sphere_d;
^~~~~~~~~~~~~~~~~~
pr11416.cpp:4:49: error: unknown type name 'Sphere_d'
template <class R> bool equal_as_sets(const Sphere_d<R>&, const Sphere_d<R>&);
^
pr11416.cpp:4:57: error: expected ')'
template <class R> bool equal_as_sets(const Sphere_d<R>&, const Sphere_d<R>&);
^
pr11416.cpp:4:42: note: to match this '('
template <class R> bool equal_as_sets(const Sphere_d<R>&, const Sphere_d<R>&);
^
pr11416.cpp:4:5: error: templates must have C++ linkage
template <class R> bool equal_as_sets(const Sphere_d<R>&, const Sphere_d<R>&);
^~~~~~~~~~~~~~~~~~With this patch only messages 'templates must have C++ linkage' are produced.
GCC also does not emit extra messages.