<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 6, 2015 at 5:39 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Mon, Apr 6, 2015 at 8:36 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
> On Mon, Apr 6, 2015 at 4:35 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> On Mon, Apr 6, 2015 at 7:30 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>><br>
>> wrote:<br>
>> > ================<br>
>> > Comment at: lib/Sema/SemaDeclAttr.cpp:2866<br>
>> > @@ -2865,1 +2865,3 @@<br>
>> ><br>
>> > +  if (E->isTypeDependent() || E->isValueDependent()) {<br>
>> > +    if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) {<br>
>> > ----------------<br>
>> > The 'type dependent' check here is redundant.<br>
>> ><br>
>> > ================<br>
>> > Comment at: lib/Sema/SemaDeclAttr.cpp:2869<br>
>> > @@ +2868,3 @@<br>
>> > +      QualType T = TND->getUnderlyingType();<br>
>> > +      if (!T->isDependentType() && !T->isInstantiationDependentType())<br>
>> > {<br>
>> > +        S.Diag(Attr.getLoc(),<br>
>> > diag::err_alignment_dependent_typedef_name)<br>
>> > ----------------<br>
>> > I don't think you should check instantiation-dependence here. I think<br>
>> > you should reject this, for instance:<br>
>> ><br>
>> >   template<int N> struct X {<br>
>> >     typedef __attribute__((aligned(N))) int X[sizeof(N)];<br>
>> >   };<br>
>> ><br>
>><br>
>> Out of curiosity, why do you think that should be rejected?<br>
><br>
><br>
> For the same reason we're rejecting anything here: we'd otherwise create a<br>
> non-dependent type that has a dependent alignment.<br>
<br>
</div></div>Huh, I guess I thought this type was dependent because of the<br>
sizeof(N) in the type.<br></blockquote><div><br></div><div>For posterity, these are approximately-correct definitions:</div><div> * value-dependent means "we don't know until instantiation whether this is a constant expression or what it evaluates to if it is"<br></div><div> * type-dependent means "we don't know until instantiation what the (canonical) type of this expression is"</div><div> * instantiation-dependent means "this refers to a template parameter in any way (and thus instantiation might possibly fail)"</div><div><br></div><div>The relevant rule:</div><div><br></div><div>"A type is dependent if it is [...]  an array type constructed from any dependent type or whose size is specified by a constant expression that is value-dependent,"</div><div><br></div><div>sizeof(N) is instantiation-dependent but not value-dependent -- its value is always sizeof(int) -- so the resulting type is an instantiation-dependent type but not a dependent type.</div></div></div></div>