From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27972 invoked by alias); 31 Aug 2008 17:53:29 -0000 Received: (qmail 27919 invoked by uid 22791); 31 Aug 2008 17:53:28 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate5.de.ibm.com (HELO mtagate5.de.ibm.com) (195.212.29.154) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 31 Aug 2008 17:52:42 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpKTa280196 for ; Sun, 31 Aug 2008 17:51:20 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7VHpKgP2478118 for ; Sun, 31 Aug 2008 19:51:20 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m7VHpK4X020021 for ; Sun, 31 Aug 2008 19:51:20 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m7VHpKjg020018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:20 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (localhost.localdomain [127.0.0.1]) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpKQ8002388 for ; Sun, 31 Aug 2008 19:51:20 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpKLd002387 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:20 +0200 Message-Id: <20080831175119.999441000@de.ibm.com> References: <20080831175045.128504000@de.ibm.com> User-Agent: quilt/0.46-1 Date: Sun, 31 Aug 2008 17:53:00 -0000 From: uweigand@de.ibm.com To: gdb-patches@sourceware.org Subject: [rfc][06/37] Eliminate builtin_type_ macros: Make OP_COMPLEX type explicit Content-Disposition: inline; filename=diff-type-complex Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00697.txt.bz2 Hello, the OP_COMPLEX expression type was hard-coded to generate a result of type "builtin_type_f_complex_s16". This should really be determined by the front-end. The following patch adds the desired result type as parameter to the OP_COMPLEX expression. Bye, Ulrich ChangeLog: * 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. Index: gdb-head/gdb/eval.c =================================================================== --- gdb-head.orig/gdb/eval.c +++ gdb-head/gdb/eval.c @@ -1369,10 +1369,11 @@ evaluate_subexp_standard (struct type *e 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); Index: gdb-head/gdb/expression.h =================================================================== --- gdb-head.orig/gdb/expression.h +++ gdb-head/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. Index: gdb-head/gdb/f-exp.y =================================================================== --- gdb-head.orig/gdb/f-exp.y +++ gdb-head/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 Index: gdb-head/gdb/parse.c =================================================================== --- gdb-head.orig/gdb/parse.c +++ gdb-head/gdb/parse.c @@ -767,7 +767,7 @@ operator_length_standard (struct express break; case OP_COMPLEX: - oplen = 1; + oplen = 3; args = 2; break; -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com