[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

Zahira Ammarguellat via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 17 06:01:21 PDT 2025


================
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fopenmp -verify %s
+// No <omp.h>; forge a typedef.
+typedef enum omp_allocator_handle_t {
+  omp_default_mem_alloc = 1,
+  __omp_allocator_handle_t_max__ = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+void foo(void) {
+  omp_allocator_handle_t my_handle;
+  int A[2];
+  // expected-error at +1 {{'omp_allocator_handle_t' type not found; include <omp.h>}}
+  #pragma omp allocate(A) allocator(my_handle)
+}
----------------
zahiraam wrote:

Is there a reason why you created 2 tests instead of just one? I think you can just a single test case. Also the naming should be with an `_` instead of an `-`, i.e `allocate_allocator_duplicate.c`.

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


More information about the cfe-commits mailing list