}
return value_nsstring (exp->gdbarch, &exp->elts[pc + 2].string, tem + 1);
- case OP_BITSTRING:
- tem = longest_to_int (exp->elts[pc + 1].longconst);
- (*pos)
- += 3 + BYTES_TO_EXP_ELEM ((tem + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT);
- if (noside == EVAL_SKIP)
- goto nosideret;
- return value_bitstring (&exp->elts[pc + 2].string, tem,
- builtin_type (exp->gdbarch)->builtin_int);
- break;
-
case OP_ARRAY:
(*pos) += 3;
tem2 = longest_to_int (exp->elts[pc + 1].longconst);
return value_slice (array, lowbound, upper - lowbound + 1);
}
- case TERNOP_SLICE_COUNT:
- {
- struct value *array = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- int lowbound
- = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
- int length
- = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
-
- return value_slice (array, lowbound, length);
- }
-
case TERNOP_COND:
/* Skip third and second args to evaluate the first one. */
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
arg1 = value_subscript (arg1, value_as_long (arg2));
break;
- case TYPE_CODE_BITSTRING:
- type = language_bool_type (exp->language_defn, exp->gdbarch);
- arg1 = value_bitstring_subscript (type, arg1,
- value_as_long (arg2));
- break;
-
default:
if (TYPE_NAME (type))
error (_("cannot subscript something of type `%s'"),
if (noside == EVAL_SKIP)
goto nosideret;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (exp->elts[pc + 1].type, lval_memory);
+ return value_zero (type, lval_memory);
else
- return value_at_lazy (exp->elts[pc + 1].type,
- value_as_address (arg1));
+ return value_at_lazy (type, value_as_address (arg1));
case UNOP_MEMVAL_TLS:
(*pos) += 3;
else
error (_("Attempt to use a type name as an expression"));
+ case OP_TYPEOF:
+ case OP_DECLTYPE:
+ if (noside == EVAL_SKIP)
+ {
+ evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+ goto nosideret;
+ }
+ else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ {
+ enum exp_opcode sub_op = exp->elts[*pos].opcode;
+ struct value *result;
+
+ result = evaluate_subexp (NULL_TYPE, exp, pos,
+ EVAL_AVOID_SIDE_EFFECTS);
+
+ /* 'decltype' has special semantics for lvalues. */
+ if (op == OP_DECLTYPE
+ && (sub_op == BINOP_SUBSCRIPT
+ || sub_op == STRUCTOP_MEMBER
+ || sub_op == STRUCTOP_MPTR
+ || sub_op == UNOP_IND
+ || sub_op == STRUCTOP_STRUCT
+ || sub_op == STRUCTOP_PTR
+ || sub_op == OP_SCOPE))
+ {
+ struct type *type = value_type (result);
+
+ if (TYPE_CODE (check_typedef (type)) != TYPE_CODE_REF)
+ {
+ type = lookup_reference_type (type);
+ result = allocate_value (type);
+ }
+ }
+
+ return result;
+ }
+ else
+ error (_("Attempt to use a type as an expression"));
+
default:
/* Removing this case and compiling with gcc -Wall reveals that
a lot of cases are hitting this case. Some of these should