[gcc/devel/omp/gcc-13] OpenMP: Fix ICE in fixup_blocks_walker [PR111274]
Tobias Burnus
burnus@gcc.gnu.org
Tue Sep 19 12:47:30 GMT 2023
https://gcc.gnu.org/g:d80ddf9e1b008f01ed4298596c2e90ac54372d93
commit d80ddf9e1b008f01ed4298596c2e90ac54372d93
Author: Sandra Loosemore <sandra@codesourcery.com>
Date: Thu Sep 7 16:12:20 2023 +0000
OpenMP: Fix ICE in fixup_blocks_walker [PR111274]
This ICE was caused by an invalid assumption that all BIND_EXPRs have
a non-null BIND_EXPR_BLOCK. In C++ these do exist and are used for
temporaries introduced in expressions that are not full-expressions.
Since they have no block to fix up, the traversal can just ignore
these tree nodes.
gcc/cp/ChangeLog
PR c++/111274
* parser.cc (fixup_blocks_walker): Check for null BIND_EXPR_BLOCK.
gcc/testsuite/ChangeLog
PR c++/111274
* g++.dg/gomp/pr111274.C: New test case.
(cherry picked from commit ab4bdad49716eb1c60e22e0e617d5eb56b0bac6f)
Diff:
---
gcc/cp/parser.cc | 5 ++++-
gcc/testsuite/g++.dg/gomp/pr111274.C | 15 +++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index dbd1f9a4f49..c8be2ccd0d1 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -45376,7 +45376,10 @@ fixup_blocks_walker (tree *tp, int *walk_subtrees, void *dp)
{
tree superblock = *(tree *)dp;
- if (TREE_CODE (*tp) == BIND_EXPR)
+ /* BIND_EXPR_BLOCK may be null if the expression is not a
+ full-expression; if there's no block, no patching is necessary
+ for this node. */
+ if (TREE_CODE (*tp) == BIND_EXPR && BIND_EXPR_BLOCK (*tp))
{
tree block = BIND_EXPR_BLOCK (*tp);
if (superblock)
diff --git a/gcc/testsuite/g++.dg/gomp/pr111274.C b/gcc/testsuite/g++.dg/gomp/pr111274.C
new file mode 100644
index 00000000000..6d3414fc82c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr111274.C
@@ -0,0 +1,15 @@
+// { dg-do "compile" }
+
+// This example used to ICE in fixup_blocks_walker due to a BIND_EXPR with
+// null BIND_EXPR_BLOCK.
+
+struct _Vector_base {
+ ~_Vector_base();
+};
+int ColumnSmallestLastOrdering_OMP_i_MaxNumThreads,
+ ColumnSmallestLastOrdering_OMP_i_MaxDegree;
+void ColumnSmallestLastOrdering_OMP() {
+#pragma omp for
+ for (int i = 0; i < ColumnSmallestLastOrdering_OMP_i_MaxNumThreads; i++)
+ new _Vector_base[ColumnSmallestLastOrdering_OMP_i_MaxDegree];
+}
More information about the Gcc-cvs
mailing list