[PATCH] D39127: Fix template parameter default args missed if redecled

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 23 00:53:39 PDT 2017


mstorsjo added inline comments.


================
Comment at: lib/Sema/SemaTemplate.cpp:4811
+  TemplateParameterList *Params =
+      cast<TemplateDecl>(Template->getMostRecentDecl())
+          ->getTemplateParameters();
----------------
erichkeane wrote:
> mstorsjo wrote:
> > erichkeane wrote:
> > > mstorsjo wrote:
> > > > How does this work if there's another forward declaration missing the parameter later? Is the logic with "most recent" ok, or should it be "most qualified/complete" instead?
> > > I'm not sure the case you mean.  Any future declarations with fewer parameters would be aspecialization and a different decl, right?
> > Sorry, I meant a declaration with fewer defaults. E.g. the original forward declaration without defaults again after the actual definition.
> > 
> > E.g. by adding
> > 
> > ```
> > namespace llvm {
> >   template<typename T > struct StringSet;
> > }
> > ```
> > before the last `namespace lld`.
> > 
> > 
> I think thats OK.  The code propagates those forward.  The problem here is that it does NOT propagate them backwards.
Ok then, then I guess it sounds fine to me, although I'm very much not familiar with this code. So I'm not comfortable with giving it a formal approval.


https://reviews.llvm.org/D39127





More information about the cfe-commits mailing list