OpenMP/C++: Reject omp_{cgroup,pteam,thread}_mem_alloc for static vars in ALLOCATE directive
Compiler now correctly rejects invalid memory allocation specifiers for static variables within OpenMP ALLOCATE directives.
This commit addresses an issue in OpenMP C++ where specific memory allocation specifiers (omp_cgroup_mem_alloc, omp_pteam_mem_alloc, omp_thread_mem_alloc) were incorrectly allowed for variables with static storage duration within an omp allocate directive. The compiler now rejects these combinations, preventing potential runtime errors or undefined behavior. The related test case was also adjusted to correct the misuse of static linkage on global variables.
In Details
This patch adds a semantic check in finish_omp_allocate to reject omp_{cgroup,pteam,thread}_mem_alloc when applied to variables with static storage duration. Static variables include globals, statics within functions, and statics within methods. The change also corrects a test case that incorrectly used static on global variables, which implies internal linkage rather than static storage duration in that context. This ensures adherence to OpenMP memory allocation semantics.
- omp allocate directive
- An OpenMP directive used to control memory allocation for data, allowing specification of memory spaces or strategies.
- static lifetime
- Variables whose storage duration lasts for the entire execution of the program, regardless of their scope.
- omp_cgroup_mem_alloc
- An OpenMP memory specifier indicating that memory should be allocated within the current cgroup context.
- omp_pteam_mem_alloc
- An OpenMP memory specifier indicating that memory should be allocated within the current parallel team context.
- omp_thread_mem_alloc
- An OpenMP memory specifier indicating that memory should be allocated within the current thread's context.