]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP: Fix ICE in fixup_blocks_walker [PR111274]
authorSandra Loosemore <sandra@codesourcery.com>
Thu, 7 Sep 2023 16:12:20 +0000 (16:12 +0000)
committerSandra Loosemore <sandra@codesourcery.com>
Thu, 7 Sep 2023 17:51:03 +0000 (17:51 +0000)
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.

gcc/cp/parser.cc
gcc/testsuite/g++.dg/gomp/pr111274.C [new file with mode: 0644]

index ed0675c95992b0e8290b392b79003f001120ab56..8808da3a8428e8172b6325f145cc020bf620c206 100644 (file)
@@ -44490,7 +44490,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 (file)
index 0000000..6d3414f
--- /dev/null
@@ -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];
+}