[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 11 13:51:41 PDT 2025
================
@@ -3445,30 +3451,27 @@ SemaOpenMP::DeclGroupPtrTy SemaOpenMP::ActOnOpenMPAllocateDirective(
else
llvm_unreachable("Unexpected clause on allocate directive");
}
+ // No forward-decl needed; just classify with null-guards.
OMPAllocateDeclAttr::AllocatorTypeTy AllocatorKind =
getAllocatorKind(SemaRef, DSAStack, Allocator);
SmallVector<Expr *, 8> Vars;
for (Expr *RefExpr : VarList) {
auto *DE = cast<DeclRefExpr>(RefExpr);
auto *VD = cast<VarDecl>(DE->getDecl());
- // Check if this is a TLS variable or global register.
+ // Skip TLS/global-registers.
if (VD->getTLSKind() != VarDecl::TLS_None ||
VD->hasAttr<OMPThreadPrivateDeclAttr>() ||
(VD->getStorageClass() == SC_Register && VD->hasAttr<AsmLabelAttr>() &&
!VD->isLocalVarDecl()))
continue;
- // If the used several times in the allocate directive, the same allocator
- // must be used.
+ // Enforce same allocator if repeated.
----------------
shafik wrote:
The previous comment is more helpful, please keep it.
https://github.com/llvm/llvm-project/pull/158146
More information about the cfe-commits
mailing list