Close gdbserver in mi_gdb_exit
[deliverable/binutils-gdb.git] / gdb / rust-exp.y
index f0c4e6c9eb78a012784c506ccc82d2e655daf9c2..6dc4704efe7c037102e03618f9d1d87e8d05173a 100644 (file)
@@ -26,7 +26,6 @@
 #include "block.h"
 #include "charset.h"
 #include "cp-support.h"
-#include "f-lang.h"
 #include "gdb_obstack.h"
 #include "gdb_regex.h"
 #include "rust-lang.h"
@@ -429,10 +428,14 @@ struct_expr_tail:
                }
 ;
 
-/* S{} is documented as valid but seems to be an unstable feature, so
-   it is left out here.  */
 struct_expr_list:
-       struct_expr_tail
+       /* %empty */
+               {
+                 VEC (set_field) **result
+                   = OBSTACK_ZALLOC (&work_obstack, VEC (set_field) *);
+                 $$ = result;
+               }
+|      struct_expr_tail
                {
                  VEC (set_field) **result
                    = OBSTACK_ZALLOC (&work_obstack, VEC (set_field) *);
@@ -969,17 +972,15 @@ super_name (const struct rust_op *ident, unsigned int n_supers)
       int i;
       int len;
       VEC (int) *offsets = NULL;
-      unsigned int current_len, previous_len;
+      unsigned int current_len;
       struct cleanup *cleanup;
 
       cleanup = make_cleanup (VEC_cleanup (int), &offsets);
       current_len = cp_find_first_component (scope);
-      previous_len = 0;
       while (scope[current_len] != '\0')
        {
          VEC_safe_push (int, offsets, current_len);
          gdb_assert (scope[current_len] == ':');
-         previous_len = current_len;
          /* The "::".  */
          current_len += 2;
          current_len += cp_find_first_component (scope
@@ -1419,6 +1420,7 @@ lex_number (void)
   int match;
   int is_integer = 0;
   int could_be_decimal = 1;
+  int implicit_i32 = 0;
   char *type_name = NULL;
   struct type *type;
   int end_index;
@@ -1437,7 +1439,10 @@ lex_number (void)
       is_integer = 1;
       end_index = subexps[INT_TEXT].rm_eo;
       if (subexps[INT_TYPE].rm_so == -1)
-       type_name = "i32";
+       {
+         type_name = "i32";
+         implicit_i32 = 1;
+       }
       else
        {
          type_index = INT_TYPE;
@@ -1479,6 +1484,7 @@ lex_number (void)
          end_index = subexps[0].rm_eo;
          type_name = "i32";
          could_be_decimal = 1;
+         implicit_i32 = 1;
        }
     }
 
@@ -1513,6 +1519,7 @@ lex_number (void)
   /* Parse the number.  */
   if (is_integer)
     {
+      uint64_t value;
       int radix = 10;
       if (number[0] == '0')
        {
@@ -1528,7 +1535,12 @@ lex_number (void)
              could_be_decimal = 0;
            }
        }
-      rustyylval.typed_val_int.val = strtoul (number, NULL, radix);
+
+      value = strtoul (number, NULL, radix);
+      if (implicit_i32 && value >= ((uint64_t) 1) << 31)
+       type = rust_type ("i64");
+
+      rustyylval.typed_val_int.val = value;
       rustyylval.typed_val_int.type = type;
     }
   else
@@ -1787,7 +1799,7 @@ ast_range (const struct rust_op *lhs, const struct rust_op *rhs)
 {
   struct rust_op *result = OBSTACK_ZALLOC (&work_obstack, struct rust_op);
 
-  result->opcode = OP_F90_RANGE;
+  result->opcode = OP_RANGE;
   result->left.op = lhs;
   result->right.op = rhs;
 
@@ -2417,9 +2429,9 @@ convert_ast_to_expression (struct parser_state *state,
       }
       break;
 
-    case OP_F90_RANGE:
+    case OP_RANGE:
       {
-       enum f90_range_type kind = BOTH_BOUND_DEFAULT;
+       enum range_type kind = BOTH_BOUND_DEFAULT;
 
        if (operation->left.op != NULL)
          {
@@ -2437,9 +2449,9 @@ convert_ast_to_expression (struct parser_state *state,
                kind = NONE_BOUND_DEFAULT;
              }
          }
-       write_exp_elt_opcode (state, OP_F90_RANGE);
+       write_exp_elt_opcode (state, OP_RANGE);
        write_exp_elt_longcst (state, kind);
-       write_exp_elt_opcode (state, OP_F90_RANGE);
+       write_exp_elt_opcode (state, OP_RANGE);
       }
       break;
 
This page took 0.024932 seconds and 4 git commands to generate.