Fix crash when exiting TUI with gdb -tui
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index feab51a8e2cb356223cf9fea1043403973cabd38..5ec84eb8ed7abcd09287c2aaab10a53f5095a44e 100644 (file)
@@ -1431,13 +1431,13 @@ scalar_type:
                                                0); }
        |       UNSIGNED type_name
                        { $$ = lookup_unsigned_typename (pstate->language (),
-                                                        TYPE_NAME($2.type)); }
+                                                        $2.type->name ()); }
        |       UNSIGNED
                        { $$ = lookup_unsigned_typename (pstate->language (),
                                                         "int"); }
        |       SIGNED_KEYWORD type_name
                        { $$ = lookup_signed_typename (pstate->language (),
-                                                      TYPE_NAME($2.type)); }
+                                                      $2.type->name ()); }
        |       SIGNED_KEYWORD
                        { $$ = lookup_signed_typename (pstate->language (),
                                                       "int"); }
@@ -1739,13 +1739,14 @@ oper:   OPERATOR NEW
 
                          c_print_type ($2, NULL, &buf, -1, 0,
                                        &type_print_raw_options);
+                         std::string name = std::move (buf.string ());
 
                          /* This also needs canonicalization.  */
-                         std::string canon
-                           = cp_canonicalize_string (buf.c_str ());
-                         if (canon.empty ())
-                           canon = std::move (buf.string ());
-                         $$ = operator_stoken ((" " + canon).c_str ());
+                         gdb::unique_xmalloc_ptr<char> canon
+                           = cp_canonicalize_string (name.c_str ());
+                         if (canon != nullptr)
+                           name = canon.get ();
+                         $$ = operator_stoken ((" " + name).c_str ());
                        }
        ;
 
@@ -1851,10 +1852,10 @@ typename_stoken (const char *type)
 static int
 type_aggregate_p (struct type *type)
 {
-  return (TYPE_CODE (type) == TYPE_CODE_STRUCT
-         || TYPE_CODE (type) == TYPE_CODE_UNION
-         || TYPE_CODE (type) == TYPE_CODE_NAMESPACE
-         || (TYPE_CODE (type) == TYPE_CODE_ENUM
+  return (type->code () == TYPE_CODE_STRUCT
+         || type->code () == TYPE_CODE_UNION
+         || type->code () == TYPE_CODE_NAMESPACE
+         || (type->code () == TYPE_CODE_ENUM
              && TYPE_DECLARED_CLASS (type)));
 }
 
@@ -1869,7 +1870,7 @@ check_parameter_typelist (std::vector<struct type *> *params)
   for (ix = 0; ix < params->size (); ++ix)
     {
       type = (*params)[ix];
-      if (type != NULL && TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID)
+      if (type != NULL && check_typedef (type)->code () == TYPE_CODE_VOID)
        {
          if (ix == 0)
            {
@@ -2747,7 +2748,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
     case '9':
       {
        /* It's a number.  */
-       int got_dot = 0, got_e = 0, toktype;
+       int got_dot = 0, got_e = 0, got_p = 0, toktype;
        const char *p = tokstart;
        int hex = input_radix > 10;
 
@@ -2767,13 +2768,16 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
            /* This test includes !hex because 'e' is a valid hex digit
               and thus does not indicate a floating point number when
               the radix is hex.  */
-           if (!hex && !got_e && (*p == 'e' || *p == 'E'))
+           if (!hex && !got_e && !got_p && (*p == 'e' || *p == 'E'))
              got_dot = got_e = 1;
+           else if (!got_e && !got_p && (*p == 'p' || *p == 'P'))
+             got_dot = got_p = 1;
            /* This test does not include !hex, because a '.' always indicates
               a decimal floating point number regardless of the radix.  */
            else if (!got_dot && *p == '.')
              got_dot = 1;
-           else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
+           else if (((got_e && (p[-1] == 'e' || p[-1] == 'E'))
+                     || (got_p && (p[-1] == 'p' || p[-1] == 'P')))
                     && (*p == '-' || *p == '+'))
              /* This is the sign of the exponent, not the end of the
                 number.  */
@@ -2786,7 +2790,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
              break;
          }
        toktype = parse_number (par_state, tokstart, p - tokstart,
-                               got_dot|got_e, &yylval);
+                               got_dot | got_e | got_p, &yylval);
         if (toktype == ERROR)
          {
            char *err_copy = (char *) alloca (p - tokstart + 1);
This page took 0.02603 seconds and 4 git commands to generate.