]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP requires: Fix diagnostic filename corner case
authorTobias Burnus <tobias@codesourcery.com>
Wed, 17 Aug 2022 13:59:06 +0000 (15:59 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 17 Aug 2022 13:59:06 +0000 (15:59 +0200)
The issue occurs when there is, e.g., main._omp_fn.0 in two files with
different OpenMP requires clauses.  The function entries in the offload
table ends up having the same decl tree and, hence, the diagnostic showed
the same filename for both.  Solution: Use the .o filename in this case.

Note that the issue does not occur with same-named 'static' functions and
without the fatal error from the requires diagnostic, there would be
later a linker error due to having two 'main'.

gcc/
* lto-cgraph.cc (input_offload_tables): Improve requires diagnostic
when filenames come out identically.

(cherry picked from commit 027b281f1e8de55d959695c7f1e80572fae6dbe7)

gcc/ChangeLog.omp
gcc/lto-cgraph.cc

index 786e3ebf2f7e1fe3627787075ea88389f6f1e67a..bd1d241ebeb16569abbd5bb9455184e000f16cd7 100644 (file)
@@ -1,3 +1,11 @@
+2022-08-17  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline:
+       2022-08-17  Tobias Burnus  <tobias@codesourcery.com>
+
+       * lto-cgraph.cc (input_offload_tables): Improve requires diagnostic
+       when filenames come out identically.
+
 2022-08-17  Tobias Burnus  <tobias@codesourcery.com>
 
        Backport from mainline:
index 6d9c36ea8b67f60ac66d0e2bf50b7f58d8a53732..39af9c1bd072c444f09778b647b8c5e82b498b17 100644 (file)
@@ -1881,6 +1881,11 @@ input_offload_tables (bool do_force_output)
                      if (tmp_decl != NULL_TREE)
                        fn2 = IDENTIFIER_POINTER (DECL_NAME (tmp_decl));
                    }
+                 if (fn1 == fn2)
+                   {
+                     fn1 = requires_fn;
+                     fn2 = file_data->file_name;
+                   }
 
                  char buf1[sizeof ("unified_address, unified_shared_memory, "
                                    "reverse_offload")];