Current version of clang cannot build the program:
template<int n> int var; int main(int argc, char *argv[]) { return var<0>; }
as linker does not find var<0>, codegen treats it as declaration only.
However this program must build succesfully, because the template
declaration is a definition as none of the conditions mentioned in
[basic.def]p2 is met. With this change codegen generates definitions
for file level variable template specialization even if the declaration
does not contain an initializer.
It's not appropriate to work around this in CodeGen. Instead, we need to fix the AST representation to distinguish between a variable template specialization definition with no initializer and a variable template specialization declaration. I'd suggest adding a flag to the AST to mark that a variable is not actually a definition despite looking like one, and use that to flag declaration-only instantiations of variable template specializations. See also D24508, where we have another use case for such a flag.