llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Chakram Siri (chakramsiri) <details> <summary>Changes</summary> 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. --- Full diff: https://github.com/llvm/llvm-project/pull/234909.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaOpenMP.cpp (+1-1) - (added) clang/test/SemaOpenMP/target-update-multidim-pointer.c (+13) ``````````diff 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 `````````` </details> https://github.com/llvm/llvm-project/pull/234909 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
