https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125377

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Missed one line in the testcase - the base declaration:

extern int omp_is_initial_device(void);

* * * 

The fail is then at:

Breakpoint 6, omp_check_for_duplicate_variant (loc=1135124,
base_decl=base_decl@entry=0x7ffff7591100, ctx=ctx@entry=0x7ffff75e6348) at
../../../repos/gcc/gcc/omp-general.cc:1562
1562              error_at (loc,
(gdb) list
1557            break;
1558
1559          tree selector = TREE_VALUE (TREE_VALUE (attr));
1560          if (omp_context_selector_compare (ctx, selector) == 0)
1561            {
1562              error_at (loc,
1563                        "multiple definitions of variants with the same "
1564                        "context selector violate the one-definition
rule");
1565              inform (DECL_SOURCE_LOCATION (TREE_PURPOSE (attr)),
1566                      "previous variant declaration here");

The problem is that 'attr' is here:

(gdb) p debug_tree(attr)
 <tree_list 0x7ffff75e65f0
    purpose <identifier_node 0x7ffff75f6820 omp declare variant base>
    value <tree_list 0x7ffff75e65c8
        purpose <function_decl 0x7ffff7213100 omp_is_initial_device.ompvariant1
type <function_type 0x7ffff742ddc8>


Namely: An identifier node, which has no source location, and not a DECL.


* * *

This particular is issue is fixed by using the following patch,
which probably breaks other code in the testsuite:

--- a/gcc/omp-general.cc
+++ b/gcc/omp-general.cc
@@ -1562,7 +1562,7 @@ omp_check_for_duplicate_variant (location_t loc, tree
base_decl, tree ctx)
          error_at (loc,
                    "multiple definitions of variants with the same "
                    "context selector violate the one-definition rule");
-         inform (DECL_SOURCE_LOCATION (TREE_PURPOSE (attr)),
+         inform (DECL_SOURCE_LOCATION (TREE_PURPOSE (TREE_VALUE (attr))),
                  "previous variant declaration here");
          return false;
        }

Reply via email to