* infptrace.c (child_resume): Don't try to step if
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index 0572e1251d4cd6f294e5f80174e05047375224dc..7316ae8a1b9d3276aa1cbddc1c52713932e7cfdb 100644 (file)
@@ -1,5 +1,5 @@
 /* YACC parser for C expressions, for GDB.
-   Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994
+   Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1996, 1997
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -298,15 +298,6 @@ exp        :       exp '.' name
                          write_exp_elt_opcode (STRUCTOP_STRUCT); }
        ;
 
-/* start-sanitize-gm
-Need to find a better way to do this...
-exp    :       exp '@' name
-                       { write_exp_elt_opcode (STRUCTOP_FIELD);
-                         write_exp_string ($3);
-                         write_exp_elt_opcode (STRUCTOP_FIELD);
-                       }
- end-sanitize-gm */
-
 exp    :       exp '.' qualified_name
                        { /* exp.type::name becomes exp.*(&type::name) */
                          /* Note: this doesn't work if name is a
@@ -604,15 +595,14 @@ qualified_name:   typebase COLONCOLON name
                            error ("`%s' is not defined as an aggregate type.",
                                   TYPE_NAME (type));
 
-                         if (!STREQ (type_name_no_tag (type), $4.ptr))
-                           error ("invalid destructor `%s::~%s'",
-                                  type_name_no_tag (type), $4.ptr);
-
                          tmp_token.ptr = (char*) alloca ($4.length + 2);
                          tmp_token.length = $4.length + 1;
                          tmp_token.ptr[0] = '~';
                          memcpy (tmp_token.ptr+1, $4.ptr, $4.length);
                          tmp_token.ptr[tmp_token.length] = 0;
+
+                         /* Check for valid destructor name.  */
+                         destructor_name_p (tmp_token.ptr, type);
                          write_exp_elt_opcode (OP_SCOPE);
                          write_exp_elt_type (type);
                          write_exp_string (tmp_token);
@@ -934,28 +924,32 @@ parse_number (p, len, parsed_float, putithere)
 
   if (parsed_float)
     {
-      char c;
-
       /* It's a float since it contains a point or an exponent.  */
+      char c;
+      int num = 0;     /* number of tokens scanned by scanf */
+      char saved_char = p[len];
 
+      p[len] = 0;      /* null-terminate the token */
       if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
-       sscanf (p, "%g", &putithere->typed_val_float.dval);
+       num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval,&c);
       else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
-       sscanf (p, "%lg", &putithere->typed_val_float.dval);
+       num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval,&c);
       else
        {
-#ifdef PRINTF_HAS_LONG_DOUBLE
-         sscanf (p, "%Lg", &putithere->typed_val_float.dval);
+#ifdef SCANF_HAS_LONG_DOUBLE
+         num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c);
 #else
          /* Scan it into a double, then assign it to the long double.
             This at least wins with values representable in the range
             of doubles. */
          double temp;
-         sscanf (p, "%lg", &temp);
+         num = sscanf (p, "%lg%c", &temp,&c);
          putithere->typed_val_float.dval = temp;
 #endif
        }
-
+      p[len] = saved_char;     /* restore the input stream */
+      if (num != 1)            /* check scanf found ONLY a float ... */
+       return ERROR;
       /* See if it has `f' or `l' suffix (float or long double).  */
 
       c = tolower (p[len - 1]);
@@ -1410,15 +1404,30 @@ yylex ()
        (c == '_' || c == '$' || (c >= '0' && c <= '9')
        || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
     {
-       if (c == '<')
-        {
-          int i = namelen;
-          while (tokstart[++i] && tokstart[i] != '>');
-          if (tokstart[i] == '>')
-            namelen = i;
-         }
-       c = tokstart[++namelen];
-     }
+      /* Template parameter lists are part of the name.
+        FIXME: This mishandles `print $a<4&&$a>3'.  */
+
+      if (c == '<')
+       {
+         int i = namelen;
+         int nesting_level = 1;
+         while (tokstart[++i])
+           {
+             if (tokstart[i] == '<')
+               nesting_level++;
+             else if (tokstart[i] == '>')
+               {
+                 if (--nesting_level == 0)
+                   break;
+               }
+           }
+         if (tokstart[i] == '>')
+           namelen = i;
+         else
+           break;
+       }
+      c = tokstart[++namelen];
+    }
 
   /* The token "if" terminates the expression and is NOT 
      removed from the input stream.  */
This page took 0.102087 seconds and 4 git commands to generate.