[PATCH] D134311: [clang] handle extended integer constant expressions in _Static_assert (PR #57687)

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 28 05:57:47 PDT 2022


aaron.ballman added a comment.

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)?



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16733
+      while (auto *BaseCast = dyn_cast<ImplicitCastExpr>(BaseExpr))
+        BaseExpr = BaseCast->getSubExpr();
+    }
----------------
tbaeder wrote:
> There is `Expr::ignoreParenImpCasts()` or `Expr::ImpCasts()` that should do this loop for you.
+1, I would use `Expr::IgnoreImpCasts()` instead of this manual loop.


================
Comment at: clang/test/Sema/static-assert.c:79
+static int static_var;
+_Static_assert(&static_var != 0, "");  // ext-warning {{'_Static_assert' is a C11 extension}} expected-warning {{comparison of address of 'static_var' not equal to a null pointer is always true}}
+_Static_assert("" != 0, "");           // ext-warning {{'_Static_assert' is a C11 extension}}
----------------
This makes it a bit easier to see there are two diagnostics expected on that line instead of just one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134311/new/

https://reviews.llvm.org/D134311



More information about the cfe-commits mailing list