[PATCH] [Sema] Don't permit dependent alignments on non-dependent typedef-names

Richard Smith richard at metafoo.co.uk
Mon Apr 6 17:36:43 PDT 2015


On Mon, Apr 6, 2015 at 4:35 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> On Mon, Apr 6, 2015 at 7:30 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
> > ================
> > Comment at: lib/Sema/SemaDeclAttr.cpp:2866
> > @@ -2865,1 +2865,3 @@
> >
> > +  if (E->isTypeDependent() || E->isValueDependent()) {
> > +    if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
> > ----------------
> > The 'type dependent' check here is redundant.
> >
> > ================
> > Comment at: lib/Sema/SemaDeclAttr.cpp:2869
> > @@ +2868,3 @@
> > +      QualType T = TND->getUnderlyingType();
> > +      if (!T->isDependentType() && !T->isInstantiationDependentType()) {
> > +        S.Diag(Attr.getLoc(),
> diag::err_alignment_dependent_typedef_name)
> > ----------------
> > I don't think you should check instantiation-dependence here. I think
> you should reject this, for instance:
> >
> >   template<int N> struct X {
> >     typedef __attribute__((aligned(N))) int X[sizeof(N)];
> >   };
> >
>
> Out of curiosity, why do you think that should be rejected?


For the same reason we're rejecting anything here: we'd otherwise create a
non-dependent type that has a dependent alignment.


>
> ~Aaron
>
> > http://reviews.llvm.org/D8693
> >
> > EMAIL PREFERENCES
> >   http://reviews.llvm.org/settings/panel/emailpreferences/
> >
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> _______________________________________________
> 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/20150406/03d9458e/attachment.html>


More information about the cfe-commits mailing list