gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / rust-exp.y
index ba145b168364c908074035f0414c34e9175dfd94..4e7878f67e1f93fe5cc4b02fe609d3eff008ee30 100644 (file)
@@ -1,5 +1,5 @@
 /* Bison parser for Rust expressions, for GDB.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
+   Copyright (C) 2016-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -38,9 +38,9 @@
 #include "gdb_regex.h"
 #include "rust-lang.h"
 #include "parser-defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
 #include "value.h"
-#include "common/vec.h"
+#include "gdbarch.h"
 
 #define GDB_YY_REMAP_PREFIX rust
 #include "yy-remap.h"
@@ -1010,7 +1010,7 @@ static const struct token_info operator_tokens[] =
 const char *
 rust_parser::copy_name (const char *name, int len)
 {
-  return (const char *) obstack_copy0 (&obstack, name, len);
+  return obstack_strndup (&obstack, name, len);
 }
 
 /* Helper function to make an stoken from a C string.  */
@@ -1610,7 +1610,7 @@ rust_parser::lex_number (YYSTYPE *lvalp)
            }
        }
 
-      value = strtoul (number.c_str () + offset, NULL, radix);
+      value = strtoulst (number.c_str () + offset, NULL, radix);
       if (implicit_i32 && value >= ((uint64_t) 1) << 31)
        type = get_type ("i64");
 
@@ -2024,7 +2024,7 @@ rust_parser::rust_lookup_type (const char *name, const struct block *block)
       return SYMBOL_TYPE (result.symbol);
     }
 
-  type = lookup_typename (language (), arch (), name, NULL, 1);
+  type = lookup_typename (language (), name, NULL, 1);
   if (type != NULL)
     return type;
 
@@ -2334,7 +2334,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
                   call expression.  */
                rust_op_vector *params = operation->right.params;
 
-               if (TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
+               if (type->code () != TYPE_CODE_NAMESPACE)
                  {
                    if (!rust_tuple_struct_type_p (type))
                      error (_("Type %s is not a tuple struct"), varname);
@@ -2413,8 +2413,8 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
              error (_("No symbol '%s' in current context"), varname);
 
            if (!want_type
-               && TYPE_CODE (type) == TYPE_CODE_STRUCT
-               && TYPE_NFIELDS (type) == 0)
+               && type->code () == TYPE_CODE_STRUCT
+               && type->num_fields () == 0)
              {
                /* A unit-like struct.  */
                write_exp_elt_opcode (pstate, OP_AGGREGATE);
@@ -2470,7 +2470,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
        if (type == NULL)
          error (_("Could not find type '%s'"), operation->left.sval.ptr);
 
-       if (TYPE_CODE (type) != TYPE_CODE_STRUCT
+       if (type->code () != TYPE_CODE_STRUCT
            || rust_tuple_type_p (type)
            || rust_tuple_struct_type_p (type))
          error (_("Struct expression applied to non-struct type"));
@@ -2603,7 +2603,8 @@ rust_lex_test_one (rust_parser *parser, const char *input, int expected)
 /* Test that INPUT lexes as the integer VALUE.  */
 
 static void
-rust_lex_int_test (rust_parser *parser, const char *input, int value, int kind)
+rust_lex_int_test (rust_parser *parser, const char *input,
+                  LONGEST value, int kind)
 {
   RUSTSTYPE result = rust_lex_test_one (parser, input, kind);
   SELF_CHECK (result.typed_val_int.val == value);
@@ -2615,17 +2616,16 @@ static void
 rust_lex_exception_test (rust_parser *parser, const char *input,
                         const char *err)
 {
-  TRY
+  try
     {
       /* The "kind" doesn't matter.  */
       rust_lex_test_one (parser, input, DECIMAL_INTEGER);
       SELF_CHECK (0);
     }
-  CATCH (except, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &except)
     {
       SELF_CHECK (strcmp (except.what (), err) == 0);
     }
-  END_CATCH
 }
 
 /* Test that INPUT lexes as the identifier, string, or byte-string
@@ -2725,8 +2725,8 @@ rust_lex_tests (void)
 {
   int i;
 
-  // Set up dummy "parser", so that rust_type works.
-  struct parser_state ps (&rust_language_defn, target_gdbarch (),
+  /* Set up dummy "parser", so that rust_type works.  */
+  struct parser_state ps (language_def (language_rust), target_gdbarch (),
                          nullptr, 0, 0, nullptr, 0, nullptr);
   rust_parser parser (&ps);
 
@@ -2782,6 +2782,7 @@ rust_lex_tests (void)
   rust_lex_int_test (&parser, "0x1_f", 0x1f, INTEGER);
   rust_lex_int_test (&parser, "0b1_101011__", 0x6b, INTEGER);
   rust_lex_int_test (&parser, "0o001177i64", 639, INTEGER);
+  rust_lex_int_test (&parser, "0x123456789u64", 0x123456789ull, INTEGER);
 
   rust_lex_test_trailing_dot (&parser);
 
@@ -2825,8 +2826,9 @@ rust_lex_tests (void)
 
 #endif /* GDB_SELF_TEST */
 
+void _initialize_rust_exp ();
 void
-_initialize_rust_exp (void)
+_initialize_rust_exp ()
 {
   int code = regcomp (&number_regex, number_regex_text, REG_EXTENDED);
   /* If the regular expression was incorrect, it was a programming
This page took 0.026279 seconds and 4 git commands to generate.