[PATCH] templated static_assert

Aaron Ballman aaron at aaronballman.com
Mon Aug 4 11:23:57 PDT 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: StaticAssert.patch
Type: application/octet-stream
Size: 1838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140804/60941ac1/attachment.obj>


More information about the cfe-commits mailing list