[FORTRAN,18/29] Use stringpool for charkind
diff mbox series

Message ID 20180905145732.404-19-rep.dot.nop@gmail.com
State New
Headers show
Series
  • [FORTRAN,01/29] gdbinit: break on gfc_internal_error
Related show

Commit Message

Bernhard Reutner-Fischer Sept. 5, 2018, 2:57 p.m. UTC
From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/fortran/ChangeLog:

2017-11-24  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* primary.c (match_charkind_name): Return stringpool node.
	(match_string_constant): Use stringpool node for name.
---
 gcc/fortran/primary.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

Patch
diff mbox series

diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index da661372c5c..cd5f81542cb 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -950,8 +950,9 @@  next_string_char (gfc_char_t delimiter, int *ret)
    the name will be detected later.  */
 
 static match
-match_charkind_name (char *name)
+match_charkind_name (const char **result)
 {
+  char buffer [GFC_MAX_SYMBOL_LEN + 1];
   locus old_loc;
   char c, peek;
   int len;
@@ -961,8 +962,8 @@  match_charkind_name (char *name)
   if (!ISALPHA (c))
     return MATCH_NO;
 
-  *name++ = c;
-  len = 1;
+  len = 0;
+  buffer[len++] = c;
 
   for (;;)
     {
@@ -976,7 +977,8 @@  match_charkind_name (char *name)
 	  if (peek == '\'' || peek == '\"')
 	    {
 	      gfc_current_locus = old_loc;
-	      *name = '\0';
+	      buffer[len] = '\0';
+	      *result = gfc_get_string ("%s", buffer);
 	      return MATCH_YES;
 	    }
 	}
@@ -986,8 +988,8 @@  match_charkind_name (char *name)
 	  && (c != '$' || !flag_dollar_ok))
 	break;
 
-      *name++ = c;
-      if (++len > GFC_MAX_SYMBOL_LEN)
+      buffer[len++] = c;
+      if (len > GFC_MAX_SYMBOL_LEN)
 	break;
     }
 
@@ -1005,9 +1007,10 @@  match_charkind_name (char *name)
 static match
 match_string_constant (gfc_expr **result)
 {
-  char name[GFC_MAX_SYMBOL_LEN + 1], peek;
+  char peek;
+  const char *name = NULL;
   size_t length;
-  int kind,save_warn_ampersand, ret;
+  int kind, save_warn_ampersand, ret;
   locus old_locus, start_locus;
   gfc_symbol *sym;
   gfc_expr *e;
@@ -1043,7 +1046,7 @@  match_string_constant (gfc_expr **result)
     {
       gfc_current_locus = old_locus;
 
-      m = match_charkind_name (name);
+      m = match_charkind_name (&name);
       if (m != MATCH_YES)
 	goto no_match;