diff mbox series

[Fortran,2/2] Fix write_omp_udr for user-operator REDUCTIONs

Message ID 20211028235259.1411169-2-rep.dot.nop@gmail.com
State New
Headers show
Series [Fortran,1/2] Add uop/name helpers | expand

Commit Message

Bernhard Reutner-Fischer Oct. 28, 2021, 11:52 p.m. UTC
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(-)
diff mbox series

Patch

diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 1328414e4f7..90ab9e275f3 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -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)