[PATCH,FORTRAN 10/29] Do not copy name for check_function_name

Bernhard Reutner-Fischer rep.dot.nop@gmail.com
Wed Sep 5 14:58:00 GMT 2018


From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

Copying the sym->name ruins pointer equality checks and first and
foremost is not needed nowadays.

gcc/fortran/ChangeLog:

2018-09-02  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* decl.c (gfc_match_volatile, gfc_match_asynchronous): Do not
	copy sym->name.
---
 gcc/fortran/decl.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 2667c2281f8..b0c45b88505 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -9167,7 +9167,6 @@ match
 gfc_match_volatile (void)
 {
   gfc_symbol *sym;
-  char *name;
   match m;
 
   if (!gfc_notify_std (GFC_STD_F2003, "VOLATILE statement at %C"))
@@ -9189,9 +9188,7 @@ gfc_match_volatile (void)
       switch (m)
 	{
 	case MATCH_YES:
-	  name = XCNEWVAR (char, strlen (sym->name) + 1);
-	  strcpy (name, sym->name);
-	  if (!check_function_name (name))
+	  if (!check_function_name (sym->name))
 	    return MATCH_ERROR;
 	  /* F2008, C560+C561. VOLATILE for host-/use-associated variable or
 	     for variable in a BLOCK which is defined outside of the BLOCK.  */
@@ -9231,7 +9228,6 @@ match
 gfc_match_asynchronous (void)
 {
   gfc_symbol *sym;
-  char *name;
   match m;
 
   if (!gfc_notify_std (GFC_STD_F2003, "ASYNCHRONOUS statement at %C"))
@@ -9253,9 +9249,7 @@ gfc_match_asynchronous (void)
       switch (m)
 	{
 	case MATCH_YES:
-	  name = XCNEWVAR (char, strlen (sym->name) + 1);
-	  strcpy (name, sym->name);
-	  if (!check_function_name (name))
+	  if (!check_function_name (sym->name))
 	    return MATCH_ERROR;
 	  if (!gfc_add_asynchronous (&sym->attr, sym->name, &gfc_current_locus))
 	    return MATCH_ERROR;
-- 
2.19.0.rc1



More information about the Fortran mailing list