[PATCH] D135199: [OpenMP][C++] Allow #pragma omp simd in constexpr functions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 5 05:51:59 PDT 2022


aaron.ballman added reviewers: shafik, erichkeane, tbaeder.
aaron.ballman added a comment.

Adding a few more reviewers who have been poking around in constant expression evaluation lately.



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2722-2723
   InGroup<CXXPre2bCompat>, DefaultIgnore;
+def err_constexpr_body_invalid_omp_simd_stmt_with_clauses : Error<
+  "OpenMP simd statement with clauses not allowed in %select{constexpr|consteval}1 %select{function|constructor}0">;
 def ext_constexpr_type_definition : ExtWarn<
----------------
You should manually re-flow this to the usual 80-col limit.


================
Comment at: clang/lib/AST/ExprConstant.cpp:8274-8279
     // Only if a local variable was declared in the function currently being
     // evaluated, do we expect to be able to find its value in the current
     // frame. (Otherwise it was likely declared in an enclosing context and
     // could either have a valid evaluatable value (for e.g. a constexpr
     // variable) or be ill-formed (and trigger an appropriate evaluation
     // diagnostic)).
----------------
This comment no longer matches the code. It also suggests that the way to address your issue is to capture the variable into the current frame -- did you explore that approach?


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2175-2178
+        SemaRef.Diag(
+            S->getBeginLoc(),
+            diag::err_constexpr_body_invalid_omp_simd_stmt_with_clauses)
+            << isa<CXXConstructorDecl>(Dcl) << Dcl->isConsteval();
----------------
C++20 now has constexpr destructors, but there are also other kinds of special member functions too. It seems like the constraint really is "constant evaluation of a function with SIMD clauses is invalid" and so we might want to go with a more generic diagnostic instead of trying to distinguish between kinds of functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135199



More information about the cfe-commits mailing list