On Mon, Aug 4, 2014 at 11:48 AM, Richard Smith <[email protected]> wrote:
> 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: > > <stdin>:1:34: error: a typedef cannot be a template > template<typename T> typedef int n; > ^ > > ... so "a static_assert declaration cannot be a template" (or "[...] > cannot be templated" or similar). > > 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.) > 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. On Mon, Aug 4, 2014 at 11:23 AM, Aaron Ballman <[email protected]> > wrote: > >> According to [temp]p1, a static_assert cannot be templated (we have a >> FIXME in the code about this as well). This patch emits a diagnostic >> turning this into an error instead of silently accepting the template >> and doing the wrong thing. Eg) >> >> struct S { >> template <typename Ty = char> >> static_assert(sizeof(Ty) != 1, "Not a char"); >> }; >> >> This code currently compiles without diagnosing, but the static_assert >> does not result in a diagnostic as you would expect. With this patch, >> the code now emits a diagnostic on the template declaration. >> >> ~Aaron >> > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
