+2021-03-09 Felix Willgerodt <felix.willgerodt@intel.com>
+
+ * f-exp.h (eval_op_f_loc): Declare.
+ (expr::fortran_loc_operation): New typedef.
+ * f-exp.y (exp): Handle UNOP_FORTRAN_LOC after parsing an
+ UNOP_INTRINSIC.
+ (f77_keywords): Add LOC keyword.
+ * f-lang.c (eval_op_f_loc): New function.
+ * std-operator.def (UNOP_FORTRAN_LOC): New operator.
+
2021-03-09 Andrew Burgess <andrew.burgess@embecosm.com>
* f-exp.h (eval_op_f_array_shape): Declare.
enum noside noside,
enum exp_opcode op,
struct value *arg1);
+extern struct value * eval_op_f_loc (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ enum exp_opcode op,
+ struct value *arg1);
/* Implement the evaluation of UNOP_FORTRAN_RANK. EXPECTED_TYPE, EXP, and
NOSIDE are as for expression::evaluate (see expression.h). OP will
eval_op_f_kind>;
using fortran_allocated_operation = unop_operation<UNOP_FORTRAN_ALLOCATED,
eval_op_f_allocated>;
+using fortran_loc_operation = unop_operation<UNOP_FORTRAN_LOC,
+ eval_op_f_loc>;
using fortran_mod_operation = binop_operation<BINOP_MOD, eval_op_f_mod>;
using fortran_modulo_operation = binop_operation<BINOP_FORTRAN_MODULO,
case UNOP_FORTRAN_SHAPE:
pstate->wrap<fortran_array_shape_operation> ();
break;
+ case UNOP_FORTRAN_LOC:
+ pstate->wrap<fortran_loc_operation> ();
+ break;
default:
gdb_assert_not_reached ("unhandled intrinsic");
}
{ "rank", UNOP_INTRINSIC, UNOP_FORTRAN_RANK, false },
{ "size", UNOP_OR_BINOP_INTRINSIC, FORTRAN_ARRAY_SIZE, false },
{ "shape", UNOP_INTRINSIC, UNOP_FORTRAN_SHAPE, false },
+ { "loc", UNOP_INTRINSIC, UNOP_FORTRAN_LOC, false },
};
/* Implementation of a dynamically expandable buffer for processing input
return value_from_longest (result_type, ndim);
}
+/* A helper function for UNOP_FORTRAN_LOC. */
+
+struct value *
+eval_op_f_loc (struct type *expect_type, struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1)
+{
+ struct type *result_type;
+ if (gdbarch_ptr_bit (exp->gdbarch) == 16)
+ result_type = builtin_f_type (exp->gdbarch)->builtin_integer_s2;
+ else if (gdbarch_ptr_bit (exp->gdbarch) == 32)
+ result_type = builtin_f_type (exp->gdbarch)->builtin_integer;
+ else
+ result_type = builtin_f_type (exp->gdbarch)->builtin_integer_s8;
+
+ LONGEST result_value = value_address (arg1);
+ return value_from_longest (result_type, result_value);
+}
+
namespace expr
{
OP (UNOP_FORTRAN_ALLOCATED)
OP (UNOP_FORTRAN_RANK)
OP (UNOP_FORTRAN_SHAPE)
+OP (UNOP_FORTRAN_LOC)
/* Two operand builtins. */
OP (BINOP_FORTRAN_CMPLX)
OP (FORTRAN_LBOUND)
OP (FORTRAN_UBOUND)
OP (FORTRAN_ASSOCIATED)
-OP (FORTRAN_ARRAY_SIZE)
\ No newline at end of file
+OP (FORTRAN_ARRAY_SIZE)
+2020-03-04 Felix Willgerodt <felix.willgerodt@intel.com>
+
+ * gdb.fortran/intrinsics.exp: Add LOC tests.
+
2021-03-09 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.fortran/shape.exp: New file.
# Test CMPLX
gdb_test "p CMPLX (4.1, 2.0)" " = \\(4.$decimal,2\\)"
+
+# Test LOC
+
+gdb_test "p/x LOC(l)" "= $hex"
+gdb_test "ptype loc(l)" "type = integer(\\*$decimal)?"