gdb: Avoid signed integer overflow when printing source lines
[deliverable/binutils-gdb.git] / gdb / f-exp.y
index e39f68417c2d7e40bb309098ba95f32fc0a6fa60..d70c66474c0eff698ea83a6c17d563afc2c80b4c 100644 (file)
@@ -1,6 +1,6 @@
 
 /* YACC parser for Fortran expressions, for GDB.
-   Copyright (C) 1986-2018 Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
 
    Contributed by Motorola.  Adapted from the C parser by Farooq Butt
    (fmbutt@engage.sps.mot.com).
@@ -72,7 +72,7 @@ int yyparse (void);
 
 static int yylex (void);
 
-void yyerror (const char *);
+static void yyerror (const char *);
 
 static void growbuf_by_size (int);
 
@@ -161,7 +161,7 @@ static int parse_number (struct parser_state *, const char *, int,
 %token BOOL_AND BOOL_OR BOOL_NOT   
 %token <lval> CHARACTER 
 
-%token <voidval> VARIABLE
+%token <voidval> DOLLAR_VARIABLE
 
 %token <opcode> ASSIGN_MODIFY
 
@@ -426,7 +426,7 @@ exp :       FLOAT
 exp    :       variable
        ;
 
-exp    :       VARIABLE
+exp    :       DOLLAR_VARIABLE
        ;
 
 exp    :       SIZEOF '(' type ')'     %prec UNARY
@@ -923,7 +923,7 @@ yylex (void)
 {
   int c;
   int namelen;
-  unsigned int i,token;
+  unsigned int token;
   const char *tokstart;
   
  retry:
@@ -937,7 +937,7 @@ yylex (void)
   
   if (*lexptr == '.')
     { 
-      for (i = 0; boolean_values[i].name != NULL; i++)
+      for (int i = 0; boolean_values[i].name != NULL; i++)
        {
          if (strncmp (tokstart, boolean_values[i].name,
                       strlen (boolean_values[i].name)) == 0)
@@ -951,7 +951,7 @@ yylex (void)
   
   /* See if it is a special .foo. operator.  */
   
-  for (i = 0; dot_ops[i].oper != NULL; i++)
+  for (int i = 0; dot_ops[i].oper != NULL; i++)
     if (strncmp (tokstart, dot_ops[i].oper,
                 strlen (dot_ops[i].oper)) == 0)
       {
@@ -1120,7 +1120,7 @@ yylex (void)
   
   /* Catch specific keywords.  */
   
-  for (i = 0; f77_keywords[i].oper != NULL; i++)
+  for (int i = 0; f77_keywords[i].oper != NULL; i++)
     if (strlen (f77_keywords[i].oper) == namelen
        && strncmp (tokstart, f77_keywords[i].oper, namelen) == 0)
       {
@@ -1135,7 +1135,7 @@ yylex (void)
   if (*tokstart == '$')
     {
       write_dollar_variable (pstate, yylval.sval);
-      return VARIABLE;
+      return DOLLAR_VARIABLE;
     }
   
   /* Use token-type TYPENAME for symbols that happen to be defined
@@ -1151,10 +1151,9 @@ yylex (void)
       VAR_DOMAIN,
       MODULE_DOMAIN
     };
-    int i;
     int hextype;
 
-    for (i = 0; i < ARRAY_SIZE (lookup_domains); ++i)
+    for (int i = 0; i < ARRAY_SIZE (lookup_domains); ++i)
       {
        /* Initialize this in case we *don't* use it in this call; that
           way we can refer to it unconditionally below.  */
@@ -1216,11 +1215,11 @@ f_parse (struct parser_state *par_state)
   return yyparse ();
 }
 
-void
+static void
 yyerror (const char *msg)
 {
   if (prev_lexptr)
     lexptr = prev_lexptr;
 
-  error (_("A %s in expression, near `%s'."), (msg ? msg : "error"), lexptr);
+  error (_("A %s in expression, near `%s'."), msg, lexptr);
 }
This page took 0.025845 seconds and 4 git commands to generate.