diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-10-06 09:25:00 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-10-06 09:25:00 +0200 |
commit | 44e20dce597328f3cb00e997fa90b95a2b710d4c (patch) | |
tree | f8b81592308489208f5a062b7e5a3db8b8cbe076 | |
parent | 3e8fb15a8cfd0e62dd474af9f536863392ed7572 (diff) | |
download | gcc-44e20dce597328f3cb00e997fa90b95a2b710d4c.zip gcc-44e20dce597328f3cb00e997fa90b95a2b710d4c.tar.gz gcc-44e20dce597328f3cb00e997fa90b95a2b710d4c.tar.bz2 |
openmp: Fix ICE in omp_discover_declare_target_tgt_fn_r
This ICEs because node->alias_target is (not yet) a FUNCTION_DECL, but
IDENTIFIER_NODE.
I guess we should retry the discovery before LTO streaming out, the reason
to do it this early is that it can affect the gimplification and omp lowering.
2020-10-06 Jakub Jelinek <jakub@redhat.com>
PR middle-end/97289
* omp-offload.c (omp_discover_declare_target_tgt_fn_r): Only follow
node->alias_target if it is a FUNCTION_DECL.
* c-c++-common/gomp/pr97289.c: New test.
-rw-r--r-- | gcc/omp-offload.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/pr97289.c | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c index 7fb3a72..590007b 100644 --- a/gcc/omp-offload.c +++ b/gcc/omp-offload.c @@ -203,7 +203,8 @@ omp_discover_declare_target_tgt_fn_r (tree *tp, int *walk_subtrees, void *data) symtab_node *node = symtab_node::get (*tp); if (node != NULL) { - while (node->alias_target) + while (node->alias_target + && TREE_CODE (node->alias_target) == FUNCTION_DECL) { if (!omp_declare_target_fn_p (node->decl) && !lookup_attribute ("omp declare target host", diff --git a/gcc/testsuite/c-c++-common/gomp/pr97289.c b/gcc/testsuite/c-c++-common/gomp/pr97289.c new file mode 100644 index 0000000..8331b95 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr97289.c @@ -0,0 +1,14 @@ +/* PR middle-end/97289 */ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ +/* { dg-skip-if "" { "hppa*-*-hpux*" "*-*-aix*" "nvptx-*-*" } } */ + +void foo (void); +static void bar (void) __attribute__ ((__weakref__ ("foo"))); + +void +baz (void) +{ +#pragma omp target + bar (); +} |