Omitted declaration

template <typename T>
struct S {
};

// S<int> v;

template struct S<int>;

Uncommenting the line above the ClassTemplateSpecializationDecl related
to the last line disappears from declarations available inside
TranslationUnitDecl.

I don't think it's expected, right?

Abramo Bagnara wrote:

template <typename T>
struct S {
};

// S<int> v;

template struct S<int>;

Uncommenting the line above the ClassTemplateSpecializationDecl related
to the last line disappears from declarations available inside
TranslationUnitDecl.

I don't think it's expected, right?
  

If it silently disappears, no. If it also complains, then I wouldn't be
surprised.

Isn't there something about explicit instantiations and implicit
instantiations not mixing?

Sebastian

It's expected (because it was written that way), but it's still a bug. Sema::ActOnExplicitInstantiation intentionally reuses existing ClassTemplateSpecializationDecl nodes from implicit instantiations, rather than always creating a new node. However, when we re-use such a node, we don't insert it into lexical context. It should be relatively easy to fix.

  - Doug

Unfortunately not so easy... we have found this code rather mess...
complex :wink:

However I've attached the patch for your review/approval.

ClassTemplate-ExplicitInst-3.patch (15.5 KB)

Sorry to annoy you, but we have other patches to submit and, you know,
patches life outside current svn tree is a bit... dangerous.

This looks okay to me.

John.

Commited in r105880.