[clang] [llvm] [OpenMP] Introduce the ompx_name clause for kernel naming (PR #200301)

Johannes Doerfert via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 1 12:06:53 PDT 2026


================
@@ -0,0 +1,48 @@
+// Test for ompx_name clause error checking
+// RUN: %clang_cc1 -std=c++20 -verify -fopenmp %s
+
+static void foo() {
+}
+
+void bar() {
+  int x = 5;
+
+  // expected-error at +1 {{argument to 'ompx_name' clause must be a string literal}}
+  #pragma omp target ompx_name(x)
+  {
+  }
+
+  // expected-error at +1 {{argument to 'ompx_name' clause must be a string literal}}
+  #pragma omp target ompx_name(123)
+  {
+  }
+
+  // This should work - string literal
+  #pragma omp target ompx_name("valid_name")
+  {
+  }
+
+// expected-note at +1 {{previous use of this kernel name is here}}
+#pragma omp target ompx_name("baz")
+  foo();
+
+// expected-warning at +1 {{OpenMP target kernel name 'baz' is used more than once in this translation unit}}
+#pragma omp target ompx_name("baz")
----------------
jdoerfert wrote:

You should get the errors at compile or runtime, but that is, for me, expected. We can add an extension later to make the name unique with a suffix, but for now, errors should be fine.

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


More information about the cfe-commits mailing list