diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2025-05-26 17:58:07 +0200 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2025-05-26 18:16:51 +0200 |
commit | 9c8e20a8425f123abd54261d03af5a956d4d01c6 (patch) | |
tree | 5395f29092f92fa03c4f0e43048f367caab740b4 | |
parent | afa69f83c6f95ff4e3a2f84eb8aed46cd65d3cb6 (diff) | |
download | gcc-9c8e20a8425f123abd54261d03af5a956d4d01c6.zip gcc-9c8e20a8425f123abd54261d03af5a956d4d01c6.tar.gz gcc-9c8e20a8425f123abd54261d03af5a956d4d01c6.tar.bz2 |
OpenMP/C++: Avoid ICE for BIND_EXPR with empty BIND_EXPR_BLOCK [PR120413]
PR c++/120413
gcc/cp/ChangeLog:
* semantics.cc (finish_omp_target_clauses_r): Handle
BIND_EXPR with empty BIND_EXPR_BLOCK.
gcc/testsuite/ChangeLog:
* g++.dg/gomp/target-4.C: New test.
(cherry picked from commit 45b849d05b733a25ec7ce612229084b8f4b86d3d)
-rw-r--r-- | gcc/cp/semantics.cc | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/gomp/target-4.C | 22 |
2 files changed, 26 insertions, 4 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index a10ef34..804c22d 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -10543,10 +10543,10 @@ finish_omp_target_clauses_r (tree *tp, int *walk_subtrees, void *ptr) if (TREE_CODE (t) == BIND_EXPR) { - tree block = BIND_EXPR_BLOCK (t); - for (tree var = BLOCK_VARS (block); var; var = DECL_CHAIN (var)) - if (!data->local_decls.contains (var)) - data->local_decls.add (var); + if (tree block = BIND_EXPR_BLOCK (t)) + for (tree var = BLOCK_VARS (block); var; var = DECL_CHAIN (var)) + if (!data->local_decls.contains (var)) + data->local_decls.add (var); return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/gomp/target-4.C b/gcc/testsuite/g++.dg/gomp/target-4.C new file mode 100644 index 0000000..80fc9df --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/target-4.C @@ -0,0 +1,22 @@ +// { dg-do compile { target c++11 } } +// PR c++/120413 + +struct S +{ + S() {} + ~S() {} +}; + +struct array +{ + S _arr[1]; +}; + +int main() +{ +#pragma omp target + { + array arr{}; + } + return 0; +} |