All the uses of primary_template_instantiation_p actually want to query whether the entity in question is a specialization of the template, not whether it's an instantiation or explicit specialization. Tested x86_64-pc-linux-gnu, applying to trunk.