sepavloff added a comment.

IIUC, the problem is observed because `Sema::getTemplateInstantiationArgs` does 
not handle the case of variable templates properly. Classes and functions are 
declaration contexts and implementation of the aforementioned function (and 
probably others) relies on this fact. Variable does not represents a context, 
and this causes errors like this. We cannot make 
`VarTemplateSpecializationDecl` a subclass of `DeclContext` because the latter 
not only serves as a host for other declarations but also supports name lookup. 
None is pertinent to the case of variable specialization.

I think, logic of `getTemplateInstantiationArgs` should be changed. The new 
implementation could inspect current instantiation 
(`Sema::ActiveTemplateInstantiations`) to check if it is an instantiation of a 
variable template. This could eliminate need of `VarTemplateSpec` and 
`VarTemplateSpecializationRAII`. Such solution looks more flexible as variable 
initializer may contain references to other variable instantiations, so single 
value of `VarTemplateSpec` is not sufficient to track instantiations.


https://reviews.llvm.org/D23096



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to