* [PATCH] OpenMP: Fix ICE in fixup_blocks_walker [PR111274]
@ 2023-09-07 16:18 Sandra Loosemore
2023-09-07 17:14 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Sandra Loosemore @ 2023-09-07 16:18 UTC (permalink / raw)
To: gcc-patches; +Cc: jakub
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
* parser.cc (fixup_blocks_walker): Check for null BIND_EXPR_BLOCK.
gcc/testsuite/ChangeLog
* g++.dg/gomp/pr111274.C: New test case
---
gcc/cp/parser.cc | 5 ++++-
gcc/testsuite/g++.dg/gomp/pr111274.C | 15 +++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/gomp/pr111274.C
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 7811d582b07..15a98019a4a 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -44485,7 +44485,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];
+}
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] OpenMP: Fix ICE in fixup_blocks_walker [PR111274]
2023-09-07 16:18 [PATCH] OpenMP: Fix ICE in fixup_blocks_walker [PR111274] Sandra Loosemore
@ 2023-09-07 17:14 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2023-09-07 17:14 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: gcc-patches
On Thu, Sep 07, 2023 at 10:18:37AM -0600, Sandra Loosemore wrote:
> 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
> * parser.cc (fixup_blocks_walker): Check for null BIND_EXPR_BLOCK.
>
> gcc/testsuite/ChangeLog
> * g++.dg/gomp/pr111274.C: New test case
Missing . at the end of the ChangeLog line.
Otherwise LGTM.
> --- a/gcc/cp/parser.cc
> +++ b/gcc/cp/parser.cc
> @@ -44485,7 +44485,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];
> +}
> --
> 2.31.1
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-07 17:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-07 16:18 [PATCH] OpenMP: Fix ICE in fixup_blocks_walker [PR111274] Sandra Loosemore
2023-09-07 17:14 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).