<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 4, 2014 at 11:48 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I don't think the diagnostic wording is right: 'template<typename T>' is not "a template declaration" in itself. A better model for the diagnostic might be this:<div>
<br></div><div>
<div><stdin>:1:34: error: a typedef cannot be a template</div><div>template<typename T> typedef int n;</div><div>                                 ^</div></div><div><br></div><div>... so "a static_assert declaration cannot be a template" (or "[...] cannot be templated" or similar).</div>

<div><br></div><div>Also, we should use the same diagnostic for the member-declaration and the non-member-declaration cases. (Right now, the non-member case gives a useless "C++ requires a type specifier" diagnostic.)</div>
</div></blockquote><div><br></div><div>Alternative approach: only check for tok::kw_static_assert in member declarations if we don't have TemplateInfo. Then, when we come to diagnose the unexpected static_assert keyword (maybe in ParseDeclarationSpecifiers or ParseImplicitInt), produce a custom diagnostic if we're within a template declaration.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 4, 2014 at 11:23 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">According to [temp]p1, a static_assert cannot be templated (we have a<br>
FIXME in the code about this as well). This patch emits a diagnostic<br>
turning this into an error instead of silently accepting the template<br>
and doing the wrong thing. Eg)<br>
<br>
struct S {<br>
  template <typename Ty = char><br>
  static_assert(sizeof(Ty) != 1, "Not a char");<br>
};<br>
<br>
This code currently compiles without diagnosing, but the static_assert<br>
does not result in a diagnostic as you would expect. With this patch,<br>
the code now emits a diagnostic on the template declaration.<br>
<span><font color="#888888"><br>
~Aaron<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>