[clang] [clang][OpenMP] Don't declare HIP's ::min and ::max in an OpenMP TU (PR #225162)

Larry Meadows via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 29 16:49:25 PDT 2026


================
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgpu-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgpu-amd-amdhsa -fopenmp-is-target-device -fsyntax-only -verify %s
+
+// The OpenMP math wrapper pulls in __clang_hip_math.h, whose ::min and ::max
+// are a CUDA compatibility extension for HIP. In an OpenMP translation unit
+// these calls are ordinary unqualified C++ lookups and must resolve to std.
+
+// expected-no-diagnostics
+
+#include <algorithm>
+#include <cmath>
+
+using namespace std;
+
+long test_min(long __a, long __b) { return min(__a, __b); }
----------------
lfmeadow wrote:

Moved it into `amdgcn_openmp_device_math.c`, which already has a C++ RUN line against the same wrappers. It's two C++-only functions with regenerated checks, and those now show the calls resolving to `std::min<long>` and `std::max<long>`. Without the header change they still fail as ambiguous.


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


More information about the cfe-commits mailing list