From: Ulrich Weigand Date: Thu, 11 Sep 2008 14:12:15 +0000 (+0000) Subject: * expression.h (enum exp_opcode): Document OP_COMPLEX to take X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c806c55a0672b52f228ce56f5bf57f065c447506;p=binutils-gdb.git * expression.h (enum exp_opcode): Document OP_COMPLEX to take a type parameter as expression element. * eval.c (evaluate_subexp_standard) [OP_COMPLEX]: Retrieve result type as expression element. * f-exp.y: Pass in type when buildin OP_COMPLEX expression. * parse.c (operator_length_standard): Update length of OP_COMPLEX. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 91869e43ca3..f98c925855a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2008-09-11 Ulrich Weigand + + * expression.h (enum exp_opcode): Document OP_COMPLEX to take + a type parameter as expression element. + * eval.c (evaluate_subexp_standard) [OP_COMPLEX]: Retrieve result + type as expression element. + * f-exp.y: Pass in type when buildin OP_COMPLEX expression. + * parse.c (operator_length_standard): Update length of OP_COMPLEX. + 2008-09-11 Ulrich Weigand * language.h (struct language_arch_info): New members diff --git a/gdb/eval.c b/gdb/eval.c index 9086e1b6b95..92b2d72e970 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1369,10 +1369,11 @@ evaluate_subexp_standard (struct type *expect_type, case OP_COMPLEX: /* We have a complex number, There should be 2 floating point numbers that compose it */ + (*pos) += 2; arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - return value_literal_complex (arg1, arg2, builtin_type_f_complex_s16); + return value_literal_complex (arg1, arg2, exp->elts[pc + 1].type); case STRUCTOP_STRUCT: tem = longest_to_int (exp->elts[pc + 1].longconst); diff --git a/gdb/expression.h b/gdb/expression.h index 4590febe804..fe5f8fc9a48 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -193,8 +193,9 @@ enum exp_opcode indicates that we have found something of the form ( ) */ OP_F77_UNDETERMINED_ARGLIST, - /* The following OP is a special one, it introduces a F77 complex - literal. It is followed by exactly two args that are doubles. */ + /* OP_COMPLEX takes a type in the following element, followed by another + OP_COMPLEX, making three exp_elements. It is followed by two double + args, and converts them into a complex number of the given type. */ OP_COMPLEX, /* OP_STRING represents a string constant. diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 1aacc378237..108f1bde414 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -328,7 +328,9 @@ complexnum: exp ',' exp ; exp : '(' complexnum ')' - { write_exp_elt_opcode(OP_COMPLEX); } + { write_exp_elt_opcode(OP_COMPLEX); + write_exp_elt_type (parse_f_type->builtin_complex_s16); + write_exp_elt_opcode(OP_COMPLEX); } ; exp : '(' type ')' exp %prec UNARY diff --git a/gdb/parse.c b/gdb/parse.c index e3a62c7a2f0..2a6b8cb25d8 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -767,7 +767,7 @@ operator_length_standard (struct expression *expr, int endpos, break; case OP_COMPLEX: - oplen = 1; + oplen = 3; args = 2; break;