Fix pthread_setname_np build error
[deliverable/binutils-gdb.git] / gdb / rust-exp.y
index 999ab25f070ee427fc5b65d9a2931c7d2b0b45ed..5587ebf5d7fcec52d080c6519807513955269d65 100644 (file)
@@ -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"
@@ -118,9 +118,6 @@ static int rustyylex (YYSTYPE *, rust_parser *);
 static void rustyyerror (rust_parser *parser, const char *msg);
 
 static struct stoken make_stoken (const char *);
-static struct block_symbol rust_lookup_symbol (const char *name,
-                                              const struct block *block,
-                                              const domain_enum domain);
 
 /* A regular expression for matching Rust numbers.  This is split up
    since it is very long and this gives us a way to comment the
@@ -241,6 +238,10 @@ struct rust_parser
   int lex_operator (YYSTYPE *lvalp);
   void push_back (char c);
 
+  void update_innermost_block (struct block_symbol sym);
+  struct block_symbol lookup_symbol (const char *name,
+                                    const struct block *block,
+                                    const domain_enum domain);
   struct type *rust_lookup_type (const char *name, const struct block *block);
   std::vector<struct type *> convert_params_to_types (rust_op_vector *params);
   struct type *convert_ast_to_type (const struct rust_op *operation);
@@ -1009,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.  */
@@ -1104,11 +1105,11 @@ rust_parser::super_name (const struct rust_op *ident, unsigned int n_supers)
 
 /* A helper that updates the innermost block as appropriate.  */
 
-static void
-update_innermost_block (struct block_symbol sym)
+void
+rust_parser::update_innermost_block (struct block_symbol sym)
 {
   if (symbol_read_needs_frame (sym.symbol))
-    innermost_block.update (sym);
+    pstate->block_tracker->update (sym);
 }
 
 /* Lex a hex number with at least MIN digits and at most MAX
@@ -1609,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");
 
@@ -1992,15 +1993,15 @@ munge_name_and_block (const char **name, const struct block **block)
 /* Like lookup_symbol, but handles Rust namespace conventions, and
    doesn't require field_of_this_result.  */
 
-static struct block_symbol
-rust_lookup_symbol (const char *name, const struct block *block,
-                   const domain_enum domain)
+struct block_symbol
+rust_parser::lookup_symbol (const char *name, const struct block *block,
+                           const domain_enum domain)
 {
   struct block_symbol result;
 
   munge_name_and_block (&name, &block);
 
-  result = lookup_symbol (name, block, domain, NULL);
+  result = ::lookup_symbol (name, block, domain, NULL);
   if (result.symbol != NULL)
     update_innermost_block (result);
   return result;
@@ -2016,14 +2017,14 @@ rust_parser::rust_lookup_type (const char *name, const struct block *block)
 
   munge_name_and_block (&name, &block);
 
-  result = lookup_symbol (name, block, STRUCT_DOMAIN, NULL);
+  result = ::lookup_symbol (name, block, STRUCT_DOMAIN, NULL);
   if (result.symbol != NULL)
     {
       update_innermost_block (result);
       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;
 
@@ -2387,8 +2388,8 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
          }
 
        varname = convert_name (operation);
-       sym = rust_lookup_symbol (varname, pstate->expression_context_block,
-                                 VAR_DOMAIN);
+       sym = lookup_symbol (varname, pstate->expression_context_block,
+                            VAR_DOMAIN);
        if (sym.symbol != NULL && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
          {
            write_exp_elt_opcode (pstate, OP_VAR_VALUE);
@@ -2602,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);
@@ -2614,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.message, err) == 0);
+      SELF_CHECK (strcmp (except.what (), err) == 0);
     }
-  END_CATCH
 }
 
 /* Test that INPUT lexes as the identifier, string, or byte-string
@@ -2726,7 +2727,7 @@ rust_lex_tests (void)
 
   // Set up dummy "parser", so that rust_type works.
   struct parser_state ps (&rust_language_defn, target_gdbarch (),
-                         nullptr, 0, 0, nullptr, 0);
+                         nullptr, 0, 0, nullptr, 0, nullptr);
   rust_parser parser (&ps);
 
   rust_lex_test_one (&parser, "", 0);
@@ -2781,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);
 
This page took 0.026872 seconds and 4 git commands to generate.