The discussion in PR #57687 turned up an inconsistency in where extended integer constant expressions are accepted: in most contexts Clang accepts boolean expressions involving string literals, it rejects them as the first argument to the _Static_assert expression. This change is my attempt to make _Static_assert consistent with the other contexts and with C++. I looked at how some of the other contexts are handled, hoping to follow their example, but couldn't find a simple way to do it. They all seem quite different from _Static_assert.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
16733 | There is Expr::ignoreParenImpCasts() or Expr::ImpCasts() that should do this loop for you. |
Comment Actions
Thank you for working on this! It looks pretty close to good, with just a few comments. Can you also add a release note for the changes as well (to clang/docs/ReleaseNotes.rst)?
clang/lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
16733 | +1, I would use Expr::IgnoreImpCasts() instead of this manual loop. | |
clang/test/Sema/static-assert.c | ||
79 | This makes it a bit easier to see there are two diagnostics expected on that line instead of just one. |
Comment Actions
Changes from previous version:
- Replace loop with Expr::IgnoreImpCasts().
- Use a multiline comment in a test to improve readability.
clang/lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
16733 | Sure. Thank you both for the suggestion! |
There is Expr::ignoreParenImpCasts() or Expr::ImpCasts() that should do this loop for you.