[Fortran,2/2] Fix write_omp_udr for user-operator REDUCTIONs
Commit Message
From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Due to a typo a user operator used in a reduction was not found in the
symtree so would have been written multiple times (in theory).
E.g. user operator ".add." was looked up as ".ad" instead of "add".
For gcc-11 branch and earlier one would
- memcpy (name, udr->name, len - 1);
+ memcpy (name, udr->name + 1, len - 1);
but for gcc-12 we have an appropriate helper already.
Jakub, please take care of non-trunk branches if you want it fixed
there.
Cc: Jakub Jelinek <jakub@redhat.com>
gcc/fortran/ChangeLog:
2017-11-16 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
* module.c (write_omp_udr): Use gfc_get_name_from_uop.
---
gcc/fortran/module.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
@@ -6021,12 +6021,8 @@ write_omp_udr (gfc_omp_udr *udr)
return;
else
{
- gfc_symtree *st;
- size_t len = strlen (udr->name + 1);
- char *name = XALLOCAVEC (char, len);
- memcpy (name, udr->name, len - 1);
- name[len - 1] = '\0';
- st = gfc_find_symtree (gfc_current_ns->uop_root, name);
+ const char *name = gfc_get_name_from_uop (udr->name);
+ gfc_symtree *st = gfc_find_symtree (gfc_current_ns->uop_root, name);
/* If corresponding user operator is private, don't write
the UDR. */
if (st != NULL)