]> 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>
Thu, 22 Apr 2021 17:14:24 +0000 (10:14 -0700)
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.c (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.c

index 566aaa4d2cfda21d830854c166e50deac868e1a5..adc28b921ac0db76c4837d8396c780c19ad31018 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-31  Sandra Loosemore  <sandra@codesourcery.com>
+
+       * semantics.c (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.c (cp_unwrap_for_init): New.
index 77616cc2efcc1b58a2ccc1056c756eb90c52a6ef..16be892c5faa83ab05e773e34e885119c395a982 100644 (file)
@@ -5056,6 +5056,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)
@@ -5370,6 +5374,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