* configure: Ignore new autoconf configure options.
[binutils-gdb.git] / gdb / ch-lang.c
index e0678268d5c210e455f977fc147060e97d576eb6..a76ae4642713a3444dbd09416e188e682035e342 100644 (file)
@@ -15,7 +15,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
 #include "symtab.h"
@@ -272,6 +272,7 @@ static const struct op_print chill_op_print_tab[] = {
     {"-",   UNOP_NEG, PREC_PREFIX, 0},
     {"->",  UNOP_IND, PREC_SUFFIX, 1},
     {"->",  UNOP_ADDR, PREC_PREFIX, 0},
+    {":",   BINOP_RANGE, PREC_ASSIGN, 0},
     {NULL,  0, 0, 0}
 };
 \f
@@ -303,11 +304,13 @@ type_lower_upper (op, type, result_type)
      struct type *type;
      struct type **result_type;
 {
-  LONGEST tmp;
-  *result_type = builtin_type_int;
+  LONGEST low, high;
+  *result_type = type;
+  CHECK_TYPEDEF (type);
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_STRUCT:
+      *result_type = builtin_type_int;
       if (chill_varying_type (type))
        return type_lower_upper (op, TYPE_FIELD_TYPE (type, 1), result_type);
       break;
@@ -318,29 +321,19 @@ type_lower_upper (op, type, result_type)
 
       /* ... fall through ... */
     case TYPE_CODE_RANGE:
-      if (TYPE_DUMMY_RANGE (type) > 0)
-       return type_lower_upper (op, TYPE_TARGET_TYPE (type), result_type);
       *result_type = TYPE_TARGET_TYPE (type);
       return op == UNOP_LOWER ? TYPE_LOW_BOUND (type) : TYPE_HIGH_BOUND (type);
 
     case TYPE_CODE_ENUM:
-      *result_type = type;
-      if (TYPE_NFIELDS (type) > 0)
-       return TYPE_FIELD_BITPOS (type,
-                                 op == UNOP_LOWER ? 0
-                                 : TYPE_NFIELDS (type) - 1);
-
     case TYPE_CODE_BOOL:
-      *result_type = type;
-      return op == UNOP_LOWER ? 0 : 1;
     case TYPE_CODE_INT:
     case TYPE_CODE_CHAR:
-      *result_type = type;
-      tmp = (LONGEST) 1 << (TARGET_CHAR_BIT * TYPE_LENGTH (type));
-      if (TYPE_UNSIGNED (type))
-       return op == UNOP_LOWER ? 0 : tmp - (LONGEST) 1;
-      tmp = tmp >> 1;
-      return op == UNOP_LOWER ? -tmp : (tmp - 1);
+      if (get_discrete_bounds (type, &low, &high) >= 0)
+       {
+         *result_type = type;
+         return op == UNOP_LOWER ? low : high;
+       }
+      break;
     case TYPE_CODE_UNDEF:
     case TYPE_CODE_PTR:
     case TYPE_CODE_UNION:
@@ -366,6 +359,7 @@ value_chill_length (val)
   LONGEST tmp;
   struct type *type = VALUE_TYPE (val);
   struct type *ttype;
+  CHECK_TYPEDEF (type);
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_ARRAY:
@@ -403,17 +397,28 @@ evaluate_subexp_chill (expect_type, exp, pos, noside)
   switch (op)
     {
     case MULTI_SUBSCRIPT:
-      if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+      if (noside == EVAL_SKIP)
        break;
       (*pos) += 3;
       nargs = longest_to_int (exp->elts[pc + 1].longconst);
       arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
+      type = check_typedef (VALUE_TYPE (arg1));
 
-      switch (TYPE_CODE (VALUE_TYPE (arg1)))
+      if (nargs == 1 && TYPE_CODE (type) == TYPE_CODE_INT)
+       {
+         /* Looks like string repetition. */
+         value_ptr string = evaluate_subexp_with_coercion (exp, pos, noside);
+         return value_concat (arg1, string);
+       }
+
+      switch (TYPE_CODE (type))
        {
        case TYPE_CODE_PTR:
        case TYPE_CODE_FUNC:
          /* It's a function call. */
+         if (noside == EVAL_AVOID_SIDE_EFFECTS)
+           break;
+
          /* Allocate arg vector, including space for the function to be
             called in argvec[0] and a terminating NULL */
          argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2));
@@ -453,6 +458,9 @@ evaluate_subexp_chill (expect_type, exp, pos, noside)
       arg1 = (*exp->language_defn->evaluate_exp) (NULL_TYPE, exp, pos, noside);
       return value_chill_length (arg1);
 
+    case BINOP_COMMA:
+      error ("',' operator used in invalid context");
+
     default:
       break;
     }