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.
+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.
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)
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