]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix bug in processing of array dimensions in data clauses.
authorSandra Loosemore <sandra@codesourcery.com>
Tue, 31 Mar 2020 21:29:09 +0000 (14:29 -0700)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Fri, 12 May 2023 18:13:46 +0000 (19:13 +0100)
The g++ front end wraps the array length and low_bound values in
NON_LVALUE_EXPR, causing the subsequent tests for INTEGER_CST to fail.
The test case c-c++-common/goacc/kernels-loop-annotation-1.c was
tickling this bug and giving bogus errors in g++ because it was falling
through to dynamic array code instead of recognizing the constant bounds.

This patch was posted upstream here
https://gcc.gnu.org/pipermail/gcc-patches/2020-March/542694.html
but not yet committed.  It may be that some other fix for this problem
is implemented on mainline instead; check before merging this patch.

2020-03-31  Sandra Loosemore  <sandra@codesourcery.com>

gcc/cp/
* semantics.cc (handle_omp_array_sections_1): Call STRIP_NOPS
on length and low_bound;
(handle_omp_array_sections): Likewise.

gcc/cp/ChangeLog.omp
gcc/cp/semantics.cc

index 74a672d653f7516580b0b2d42cca1009c595555a..ead9de41a2c9c42281528a33eeaeb3cffbae1216 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-31  Sandra Loosemore  <sandra@codesourcery.com>
+
+       * semantics.cc (handle_omp_array_sections_1): Call STRIP_NOPS
+       on length and low_bound;
+       (handle_omp_array_sections): Likewise.
+
 2020-03-27  Sandra Loosemore  <sandra@codesourcery.com>
 
        * decl.cc (cp_unwrap_for_init): New.
index e7d622956095c249b6a3552c5b06ed95e4f4a885..24b92c199afab38389503a9ae22196f8f3e575a0 100644 (file)
@@ -5263,6 +5263,10 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
   if (length)
     length = mark_rvalue_use (length);
   /* We need to reduce to real constant-values for checks below.  */
+  if (length)
+    STRIP_NOPS (length);
+  if (low_bound)
+    STRIP_NOPS (low_bound);
   if (length)
     length = fold_simple (length);
   if (low_bound)
@@ -5595,6 +5599,11 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
          tree low_bound = TREE_PURPOSE (t);
          tree length = TREE_VALUE (t);
 
+         if (length)
+           STRIP_NOPS (length);
+         if (low_bound)
+           STRIP_NOPS (low_bound);
+
          i--;
          if (low_bound
              && TREE_CODE (low_bound) == INTEGER_CST