[llvm-branch-commits] [clang] [llvm] [OpenMP][clang] 6.0: num_threads strict (part 3: codegen) (PR #146405)

Robert Imschweiler via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 1 06:50:16 PDT 2025


================
@@ -16445,11 +16450,18 @@ OMPClause *SemaOpenMP::ActOnOpenMPMessageClause(Expr *ME,
                                                 SourceLocation LParenLoc,
                                                 SourceLocation EndLoc) {
   assert(ME && "NULL expr in Message clause");
-  if (!isa<StringLiteral>(ME)) {
+  QualType Type = ME->getType();
+  if ((!Type->isPointerType() && !Type->isArrayType()) ||
+      !Type->getPointeeOrArrayElementType()->isAnyCharacterType()) {
     Diag(ME->getBeginLoc(), diag::warn_clause_expected_string)
         << getOpenMPClauseNameForDiag(OMPC_message);
     return nullptr;
   }
+
+  // Convert array type to pointer type if needed.
+  if (Type->isArrayType())
+    ME = SemaRef.DefaultFunctionArrayConversion(ME).get();
----------------
ro-i wrote:

```c++
ExprResult Sema::DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose) {
  ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
  if (Res.isInvalid())
    return ExprError();
  Res = DefaultLvalueConversion(Res.get());
  if (Res.isInvalid())
    return ExprError();
  return Res;
}
```
That function directly starts with `DefaultFunctionArrayConversion`, which I had previously. So I wouldn't have needed the check anyway, I guess. What would be the difference in this case between `DefaultFunctionArrayConversion` and `DefaultFunctionArrayLvalueConversion` (= `DefaultFunctionArrayConversion` + `DefaultLvalueConversion`)? So what effect would `DefaultLvalueConversion` have here?

https://github.com/llvm/llvm-project/pull/146405


More information about the llvm-branch-commits mailing list