Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2020-10-06  Jakub Jelinek  <ja...@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.

--- gcc/omp-offload.c.jj        2020-10-01 10:40:10.000000000 +0200
+++ gcc/omp-offload.c   2020-10-05 11:45:40.450501897 +0200
@@ -203,7 +203,8 @@ omp_discover_declare_target_tgt_fn_r (tr
       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",
--- gcc/testsuite/c-c++-common/gomp/pr97289.c.jj        2020-10-05 
11:48:58.818623202 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr97289.c   2020-10-05 11:48:38.631916154 
+0200
@@ -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 ();
+}


        Jakub

Reply via email to