[clang] [clang][OpenMP] Reject non-narrow string literals in the message clause (PR #226080)
Akash Manna via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 06:19:18 PDT 2026
================
@@ -19238,8 +18369,13 @@ OMPClause *SemaOpenMP::ActOnOpenMPMessageClause(Expr *ME,
SourceLocation EndLoc) {
assert(ME && "NULL expr in Message clause");
QualType Type = ME->getType();
- if ((!Type->isPointerType() && !Type->isArrayType()) ||
- !Type->getPointeeOrArrayElementType()->isAnyCharacterType()) {
+ // The message is consumed as a narrow string by Sema and the runtime.
+ bool IsNarrowString = false;
+ if (Type->isPointerType() || Type->isArrayType()) {
+ const auto *ElemTy = Type->getPointeeOrArrayElementType();
+ IsNarrowString = ElemTy->isCharType() || ElemTy->isChar8Type();
----------------
akash-manna-sky wrote:
The spec defines `msg-string` as a string of `const char *` type (OpenMP 5.1 ยง2.5.4), and the runtime entry points `__kmpc_error` and `__kmpc_push_num_threads_strict` take `const char *` as well, so a wide string can't be passed through for `at(execution)`. GCC rejects it too.
https://github.com/llvm/llvm-project/pull/226080
More information about the cfe-commits
mailing list