[PATCH] N3651 -- Variable Templates -- A first (incremental) step.

Larisse Voufo lvoufo at google.com
Fri Jun 21 14:17:13 PDT 2013


Thanks. Comments noted. I'm working on clean up + tests cases.
I am however finding that some important test cases require support for
explicit specializations
(not necessarily partial specialization yet).
So I'm trying to complete that part as well before the next (partial) patch.



On Tue, Jun 18, 2013 at 7:00 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> Hi Larisse,
>
> This looks like a great start!
>
> Adding two pointers to every VarDecl to support this seems like quite
> a high cost to pay. The DefinitionData field looks unnecessary (we can
> reconstruct the definition by following the redeclaration chain
> already), and if you drop that you should be able to remove the extra
> parameter to VarDecl::Create too. Can you find somewhere else to hang
> the TemplateOrInstantiation data, so we don't need to pay for it if we
> don't use it? (Maybe derive from the ExtInfo in DeclaratorDecl and put
> the data there, or add a class derived from VarDecl for the cases
> where we need this data, or put it in a DenseMap on the ASTContext.)
>
> +      return IsVarTemplate? NameClassification::TypeTemplate(Template)
> +              : NameClassification::VarTemplate(Template);
>
> This looks backwards.
>
> +      if (!getLangOpts().CPlusPlus1y) {
> +        if (TemplateParams->size() > 0) {
> +          // There is no such thing as a variable template.
> +          Diag(D.getIdentifierLoc(), diag::err_template_variable)
> +            << II
> +            << SourceRange(TemplateParams->getTemplateLoc(),
> +                           TemplateParams->getRAngleLoc());
>
> Can you downgrade this from an Error to an ExtWarn? There doesn't seem
> to be a good reason not to support variable templates as an extension
> in all C++ language modes.
>
> This patch needs some cleaning up to prepare for check in (removing
> commented-out code etc), and a lot more tests; I suggest going over
> the patch and trying to add some tests for every change, where that's
> possible. Other than that, this seems close to being ready to commit,
> as a first step towards variable templates.
>
> Thank you!
>
> On Tue, Jun 18, 2013 at 5:50 PM, Larisse Voufo <lvoufo at google.com> wrote:
> > There was a bug in this earlier version of the patch. The correction is
> > attached.
> >
> >
> > On Wed, Jun 12, 2013 at 6:52 PM, Larisse Voufo <lvoufo at google.com>
> wrote:
> >>
> >> Hello --
> >>
> >> I have  started implementing variable templates, and you can find
> attached
> >> the current state.
> >> While it may cover more cases, the only guarantee it has is that top
> level
> >> variable templates can be declared and used (as illustrated in the
> >> SemaCXX/cxx1y-variable-templates.cpp test file). That is, it does not
> yet
> >> cover any of the following:
> >>
> >> * variable template explicit (partial) specialization and
> instantiations,
> >> * static member variable templates,
> >> * constexpr variables, and
> >> * default variable template arguments.
> >>
> >> Things will get much cleaner as I complete the implementation.
> >>
> >> Thanks,
> >> -- Larisse.
> >>
> >>
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130621/16ffcf95/attachment.html>


More information about the cfe-commits mailing list