[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 25 14:39:38 PST 2021


aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, jyknight.
aaron.ballman requested review of this revision.

I noticed that our diagnostics relating to static assertions are a bit confused. For instance, when in MS compatibility mode in C (where we accept `static_assert` even without including `<assert.h>`), we would fail to warn the user that they were using the wrong spelling (even in pedantic mode), we were missing a compatibility warning about using `_Static_assert` in earlier standards modes, diagnostics for the optional message were not reflected in C as they were in C++, etc.

This patch improves the diagnostic functionality in both C and C++ mode. It adds `-Wc89-c99-c11-c17-compat` and `-Wc89-c99-c11-c17-compat-pedantic` diagnostics groups and adds new C-specific diagnostics for a static assertion without a diagnostic message.


https://reviews.llvm.org/D95396

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/static_assert.c
  clang/test/SemaCXX/static-assert.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95396.319123.patch
Type: text/x-patch
Size: 7858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210125/ba9a7b74/attachment.bin>


More information about the cfe-commits mailing list