Fix a new warning on Cygwin
[binutils-gdb.git] / gdb / rust-parse.c
index 8be7d33cfe98a27a2049da37ac9424dc52b7e4ca..7d7d882872cec6e4898c1847528da840afd03eb3 100644 (file)
 
 using namespace expr;
 
-#if WORDS_BIGENDIAN
-#define UTF32 "UTF-32BE"
-#else
-#define UTF32 "UTF-32LE"
-#endif
-
 /* 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
    sections.  */
@@ -277,7 +271,10 @@ struct rust_parser
   operation_up parse_entry_point ()
   {
     lex ();
-    return parse_expr ();
+    operation_up result = parse_expr ();
+    if (current_token != 0)
+      error (_("Syntax error near '%s'"), pstate->prev_lexptr);
+    return result;
   }
 
   operation_up parse_tuple ();
@@ -458,7 +455,7 @@ rust_parser::rust_lookup_type (const char *name)
   if (result.symbol != NULL)
     {
       update_innermost_block (result);
-      return SYMBOL_TYPE (result.symbol);
+      return result.symbol->type ();
     }
 
   type = lookup_typename (language (), name, NULL, 1);
@@ -601,7 +598,8 @@ lex_multibyte_char (const char *text, int *len)
     return 0;
 
   auto_obstack result;
-  convert_between_encodings (host_charset (), UTF32, (const gdb_byte *) text,
+  convert_between_encodings (host_charset (), HOST_UTF32,
+                            (const gdb_byte *) text,
                             quote, 1, &result, translit_none);
 
   int size = obstack_object_size (&result);
@@ -732,7 +730,8 @@ rust_parser::lex_string ()
          if (is_byte)
            obstack_1grow (&obstack, value);
          else
-           convert_between_encodings (UTF32, "UTF-8", (gdb_byte *) &value,
+           convert_between_encodings (HOST_UTF32, "UTF-8",
+                                      (gdb_byte *) &value,
                                       sizeof (value), sizeof (value),
                                       &obstack, translit_none);
        }
@@ -1210,15 +1209,15 @@ rust_parser::name_to_operation (const std::string &name)
   struct block_symbol sym = lookup_symbol (name.c_str (),
                                           pstate->expression_context_block,
                                           VAR_DOMAIN);
-  if (sym.symbol != nullptr && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
+  if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF)
     return make_operation<var_value_operation> (sym);
 
   struct type *type = nullptr;
 
   if (sym.symbol != nullptr)
     {
-      gdb_assert (SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF);
-      type = SYMBOL_TYPE (sym.symbol);
+      gdb_assert (sym.symbol->aclass () == LOC_TYPEDEF);
+      type = sym.symbol->type ();
     }
   if (type == nullptr)
     type = rust_lookup_type (name.c_str ());
@@ -2024,6 +2023,7 @@ rust_parser::parse_atom (bool required)
 
     case STRING:
       result = parse_string ();
+      lex ();
       break;
 
     case BYTESTRING: