[PATCH] D155175: [Clang] Fix consteval propagation for aggregates and defaulted constructors

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 03:07:47 PDT 2023


Fznamznon added a comment.

Just a couple of NITs otherwise LGTM



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2506
+
+      for (auto A : E->arguments())
+        if (!getDerived().TraverseStmt(A))
----------------



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2546
   } Visitor(*this, FD);
-  Visitor.TraverseStmt(FD->getBody());
+  Visitor.TraverseDecl(const_cast<FunctionDecl *>(FD));
 }
----------------
Maybe it makes sense to drop `const` from `FD` parameter instead of doing a `const_cast`?


================
Comment at: clang/test/SemaCXX/cxx2a-consteval-default-params.cpp:48
 
-struct InitWithLambda {
-    int b = [](int error = undefined()) { // expected-error {{cannot take address of consteval function 'undefined' outside of an immediate invocation}}
+struct InitWithLambda { // expected-note {{'InitWithLambda' is an immediate constructor because the default initializer of 'b' contains a call to a consteval function 'undefined' and that call is not a constant expression}}
+    int b = [](int error = undefined()) {  // expected-note {{undefined function 'undefined' cannot be used in a constant expression}}
----------------
Maybe it makes sense to print `InitWithLambda::InitWithLambda` so it looks same as "call to immediate function ... is not a constant expression" message and makes it more obvious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155175



More information about the cfe-commits mailing list