https://github.com/chakramsiri created https://github.com/llvm/llvm-project/pull/234909
Fixes #144827. The issue was a compilation error in Clang when using the OpenMP `target update` directive with explicitly sized multidimensional pointer array sections. Updated the array-section validation in `SemaOpenMP.cpp` to handle explicitly specified section lengths and added a regression test in `target-update-multidim-pointer.c`. ## Testing - `./build/bin/clang -cc1 -fopenmp -fopenmp-version=50 -fsyntax-only -verify clang/test/SemaOpenMP/target-update-multidim-pointer.c` — **Passed** - **Before the fix:** The original reproducer failed to compile due to an error about an unspecified section length. - **After the fix:** The original reproducer compiled successfully with the modified Clang. - **Missing-length case:** Expected diagnostics were produced, confirming that invalid sections are still rejected. GenAI (ChatGPT) assisted with understanding the source code, debugging the issue, and developing edge-case tests. >From d524dc52b2117d310250994727d6cb234f582cff Mon Sep 17 00:00:00 2001 From: Siri Chakram <[email protected]> Date: Fri, 23 Oct 2026 16:00:39 +0530 Subject: [PATCH] [OpenMP] Fix target update for multidimensional pointer sections --- clang/lib/Sema/SemaOpenMP.cpp | 2 +- .../SemaOpenMP/target-update-multidim-pointer.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaOpenMP/target-update-multidim-pointer.c diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index efe8c9338b5a9e..b4c73e8b4cb1b8 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -24259,7 +24259,7 @@ class MapBaseChecker final : public StmtVisitor<MapBaseChecker, bool> { AllowWholeSizeArraySection = false; } else if (DKind == OMPD_target_update && SemaRef.getLangOpts().OpenMP >= 50) { - if (IsPointer && !AllowAnotherPtr) + if (IsPointer && !AllowAnotherPtr && !OASE->getLength()) SemaRef.Diag(ELoc, diag::err_omp_section_length_undefined) << /*array of unknown bound */ 1; else diff --git a/clang/test/SemaOpenMP/target-update-multidim-pointer.c b/clang/test/SemaOpenMP/target-update-multidim-pointer.c new file mode 100644 index 00000000000000..139ea4e31cb7a5 --- /dev/null +++ b/clang/test/SemaOpenMP/target-update-multidim-pointer.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fsyntax-only -verify %s + +void test_valid(int **a) { + #pragma omp target data map(to: a[0:1][0:100]) + { + #pragma omp target update from(a[0:1][0:100]) + } +} + +void test_missing_length(int **a) { + #pragma omp target update from(a[0:1][0:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} + // expected-error@-1 {{expected at least one 'to' clause or 'from' clause specified}} +} \ No newline at end of file _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
