Before the patch, the compiler would crash for the test due to inconsistent linkage.
This patch tries to avoid it by make the linkage consistent for template and its specialization. After the patch, the behavior of compiler would be partially correct for the case.
The correct one is:
export template<class T> void f() {} template<> void f<int>() {}
In this case, the linkage for both declaration should be external (the wording I get by consulting in WG21 is "the linkage for name f should be external").
And for the case:
template<class T> void f() {} export template<> void f<int>() {}
Compiler should reject it. This isn't done now. I marked it as FIXME in the test. After all, this patch would stop a crash.
The mangled name should contain module name if D118352 is ready.