[PATCH] D154290: [Clang] Implement P2741R3 - user-generated static_assert messages

Sergei Barannikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 8 09:54:28 PDT 2023


barannikov88 added inline comments.


================
Comment at: clang/include/clang/Sema/Sema.h:3883
+                                  ///< message.
+    CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
+                                  ///< message.
----------------
Appears unused.


================
Comment at: clang/lib/AST/ExprConstant.cpp:16413
+    APSInt C = Char.getInt();
+    Result.push_back(static_cast<char>(C.getExtValue()));
+    if (!HandleLValueArrayAdjustment(Info, PtrExpression, String, CharTy, 1))
----------------
This relies on host's CHAR_BIT >= target's CHAR_BIT, which isn't true for my target. Could you add an assertion?



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16960
+  ExprResult EvaluatedData = BuildConvertedConstantExpression(
+      DataE.get(), ConstCharPtr, CCEK_StaticAssertMessageSize);
+  if (EvaluatedData.isInvalid()) {
----------------



================
Comment at: clang/test/SemaCXX/static-assert-cxx26.cpp:127
+};
+static_assert(false, RAII{}); // expected-error {{static assertion failed: ok}}
----------------
Should there be (negative?) tests with non-const data/size members and incorrect number of parameters? These conditions are checked in FindMember.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290



More information about the cfe-commits mailing list