gdb: Fix build failure with GCC 7
[deliverable/binutils-gdb.git] / gdb / expprint.c
index 97188edcb6512773acc7058860da598996500b8c..9b8ac4c070b4db0729eff48261405ab8117492ad 100644 (file)
@@ -1,6 +1,6 @@
 /* Print in infix form a struct expression.
 
-   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "parser-defs.h"
 #include "user-regs.h"         /* For user_reg_map_regnum_to_name.  */
 #include "target.h"
-#include <string.h>
 #include "block.h"
 #include "objfiles.h"
-#include "gdb_assert.h"
 #include "valprint.h"
 
 #include <ctype.h>
@@ -64,7 +62,7 @@ print_subexp_standard (struct expression *exp, int *pos,
   const struct op_print *op_print_tab;
   int pc;
   unsigned nargs;
-  char *op_str;
+  const char *op_str;
   int assign_modify = 0;
   enum exp_opcode opcode;
   enum precedence myprec = PREC_NULL;
@@ -242,7 +240,7 @@ print_subexp_standard (struct expression *exp, int *pos,
          {
            char *s, *nextS;
 
-           s = alloca (strlen (selector) + 1);
+           s = (char *) alloca (strlen (selector) + 1);
            strcpy (s, selector);
            for (tem = 0; tem < nargs; tem++)
              {
@@ -282,7 +280,7 @@ print_subexp_standard (struct expression *exp, int *pos,
             a simple string, revert back to array printing.  Note that
             the last expression element is an explicit null terminator
             byte, which doesn't get printed.  */
-         tempstr = alloca (nargs);
+         tempstr = (char *) alloca (nargs);
          pc += 4;
          while (tem < nargs)
            {
@@ -561,6 +559,26 @@ print_subexp_standard (struct expression *exp, int *pos,
        return;
       }
 
+    case OP_RANGE:
+      {
+       enum range_type range_type;
+
+       range_type = (enum range_type)
+         longest_to_int (exp->elts[pc + 1].longconst);
+       *pos += 2;
+
+       fputs_filtered ("RANGE(", stream);
+       if (range_type == HIGH_BOUND_DEFAULT
+           || range_type == NONE_BOUND_DEFAULT)
+         print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
+       fputs_filtered ("..", stream);
+       if (range_type == LOW_BOUND_DEFAULT
+           || range_type == NONE_BOUND_DEFAULT)
+         print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
+       fputs_filtered (")", stream);
+       return;
+      }
+
       /* Default ops */
 
     default:
@@ -631,7 +649,7 @@ print_subexp_standard (struct expression *exp, int *pos,
 /* Return the operator corresponding to opcode OP as
    a string.   NULL indicates that the opcode was not found in the
    current language table.  */
-char *
+const char *
 op_string (enum exp_opcode op)
 {
   int tem;
@@ -651,7 +669,7 @@ static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
 
 /* Name for OPCODE, when it appears in expression EXP.  */
 
-char *
+const char *
 op_name (struct expression *exp, enum exp_opcode opcode)
 {
   return exp->language_defn->la_exp_desc->op_name (opcode);
@@ -660,7 +678,7 @@ op_name (struct expression *exp, enum exp_opcode opcode)
 /* Default name for the standard operator OPCODE (i.e., one defined in
    the definition of enum exp_opcode).  */
 
-char *
+const char *
 op_name_standard (enum exp_opcode opcode)
 {
   switch (opcode)
@@ -685,10 +703,9 @@ op_name_standard (enum exp_opcode opcode)
 
 void
 dump_raw_expression (struct expression *exp, struct ui_file *stream,
-                    char *note)
+                    const char *note)
 {
   int elt;
-  char *opcode_name;
   char *eltscan;
   int eltsize;
 
@@ -704,9 +721,10 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream,
   for (elt = 0; elt < exp->nelts; elt++)
     {
       fprintf_filtered (stream, "\t%5d  ", elt);
-      opcode_name = op_name (exp, exp->elts[elt].opcode);
 
+      const char *opcode_name = op_name (exp, exp->elts[elt].opcode);
       fprintf_filtered (stream, "%20s  ", opcode_name);
+
       print_longest (stream, 'd', 0, exp->elts[elt].longconst);
       fprintf_filtered (stream, "  ");
 
@@ -802,8 +820,6 @@ dump_subexp_body_standard (struct expression *exp,
     case BINOP_ASSIGN_MODIFY:
     case BINOP_VAL:
     case BINOP_CONCAT:
-    case BINOP_IN:
-    case BINOP_RANGE:
     case BINOP_END:
     case STRUCTOP_MEMBER:
     case STRUCTOP_MPTR:
@@ -1011,12 +1027,65 @@ dump_subexp_body_standard (struct expression *exp,
        elt = dump_subexp (exp, stream, elt);
       }
       break;
+    case OP_STRING:
+      {
+       LONGEST len = exp->elts[elt].longconst;
+       LONGEST type = exp->elts[elt + 1].longconst;
+
+       fprintf_filtered (stream, "Language-specific string type: %s",
+                         plongest (type));
+
+       /* Skip length.  */
+       elt += 1;
+
+       /* Skip string content. */
+       elt += BYTES_TO_EXP_ELEM (len);
+
+       /* Skip length and ending OP_STRING. */
+       elt += 2;
+      }
+      break;
+    case OP_RANGE:
+      {
+       enum range_type range_type;
+
+       range_type = (enum range_type)
+         longest_to_int (exp->elts[elt].longconst);
+       elt += 2;
+
+       switch (range_type)
+         {
+         case BOTH_BOUND_DEFAULT:
+           fputs_filtered ("Range '..'", stream);
+           break;
+         case LOW_BOUND_DEFAULT:
+           fputs_filtered ("Range '..EXP'", stream);
+           break;
+         case HIGH_BOUND_DEFAULT:
+           fputs_filtered ("Range 'EXP..'", stream);
+           break;
+         case NONE_BOUND_DEFAULT:
+           fputs_filtered ("Range 'EXP..EXP'", stream);
+           break;
+         default:
+           fputs_filtered ("Invalid Range!", stream);
+           break;
+         }
+
+       if (range_type == HIGH_BOUND_DEFAULT
+           || range_type == NONE_BOUND_DEFAULT)
+         elt = dump_subexp (exp, stream, elt);
+       if (range_type == LOW_BOUND_DEFAULT
+           || range_type == NONE_BOUND_DEFAULT)
+         elt = dump_subexp (exp, stream, elt);
+      }
+      break;
+
     default:
     case OP_NULL:
     case MULTI_SUBSCRIPT:
     case OP_F77_UNDETERMINED_ARGLIST:
     case OP_COMPLEX:
-    case OP_STRING:
     case OP_BOOL:
     case OP_M2_STRING:
     case OP_THIS:
This page took 0.031585 seconds and 4 git commands to generate.