From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5357 invoked by alias); 10 May 2010 20:17:46 -0000 Received: (qmail 5346 invoked by uid 22791); 10 May 2010 20:17:44 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 May 2010 20:17:38 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4AKHblG030314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 May 2010 16:17:37 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4AKHaZf029205; Mon, 10 May 2010 16:17:37 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o4AKHak0025772; Mon, 10 May 2010 16:17:36 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id BABC3378012; Mon, 10 May 2010 14:17:35 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: remove a couple uses of current_language Reply-To: tromey@redhat.com Date: Mon, 10 May 2010 20:17:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-05/txt/msg00229.txt.bz2 I'm checking this in. This removes a couple uses of current_language from the expression evaluator. It particular it removes the uses from ptrmath_type_p and from CAST_IS_CONVERSION. Built and regtested on x86-64 (compile farm). More uses of current_language remain, but they are buried in valops.c and perhaps elsewhere, not eval.c. Ultimately I would like to see all these uses removed. Ideally the expression evaluator should not depend on any globals. Tom 2010-05-10 Tom Tromey * eval.c (ptrmath_type_p): Add 'lang' argument. (evaluate_subexp_standard): Update. (evaluate_subexp_with_coercion): Update. * language.h (CAST_IS_CONVERSION): Add 'LANG' argument. Index: eval.c =================================================================== RCS file: /cvs/src/src/gdb/eval.c,v retrieving revision 1.131 diff -u -r1.131 eval.c --- eval.c 7 May 2010 14:46:26 -0000 1.131 +++ eval.c 10 May 2010 19:42:44 -0000 @@ -633,7 +633,7 @@ } static int -ptrmath_type_p (struct type *type) +ptrmath_type_p (const struct language_defn *lang, struct type *type) { type = check_typedef (type); if (TYPE_CODE (type) == TYPE_CODE_REF) @@ -646,7 +646,7 @@ return 1; case TYPE_CODE_ARRAY: - return current_language->c_style_arrays; + return lang->c_style_arrays; default: return 0; @@ -1906,10 +1906,12 @@ op = exp->elts[pc + 1].opcode; if (binop_user_defined_p (op, arg1, arg2)) return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside); - else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1)) + else if (op == BINOP_ADD && ptrmath_type_p (exp->language_defn, + value_type (arg1)) && is_integral_type (value_type (arg2))) arg2 = value_ptradd (arg1, value_as_long (arg2)); - else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1)) + else if (op == BINOP_SUB && ptrmath_type_p (exp->language_defn, + value_type (arg1)) && is_integral_type (value_type (arg2))) arg2 = value_ptradd (arg1, - value_as_long (arg2)); else @@ -1935,10 +1937,10 @@ goto nosideret; if (binop_user_defined_p (op, arg1, arg2)) return value_x_binop (arg1, arg2, op, OP_NULL, noside); - else if (ptrmath_type_p (value_type (arg1)) + else if (ptrmath_type_p (exp->language_defn, value_type (arg1)) && is_integral_type (value_type (arg2))) return value_ptradd (arg1, value_as_long (arg2)); - else if (ptrmath_type_p (value_type (arg2)) + else if (ptrmath_type_p (exp->language_defn, value_type (arg2)) && is_integral_type (value_type (arg1))) return value_ptradd (arg2, value_as_long (arg1)); else @@ -1954,14 +1956,14 @@ goto nosideret; if (binop_user_defined_p (op, arg1, arg2)) return value_x_binop (arg1, arg2, op, OP_NULL, noside); - else if (ptrmath_type_p (value_type (arg1)) - && ptrmath_type_p (value_type (arg2))) + else if (ptrmath_type_p (exp->language_defn, value_type (arg1)) + && ptrmath_type_p (exp->language_defn, value_type (arg2))) { /* FIXME -- should be ptrdiff_t */ type = builtin_type (exp->gdbarch)->builtin_long; return value_from_longest (type, value_ptrdiff (arg1, arg2)); } - else if (ptrmath_type_p (value_type (arg1)) + else if (ptrmath_type_p (exp->language_defn, value_type (arg1)) && is_integral_type (value_type (arg2))) return value_ptradd (arg1, - value_as_long (arg2)); else @@ -2031,8 +2033,8 @@ error (_("':' operator used in invalid context")); case BINOP_SUBSCRIPT: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); + arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); + arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; if (binop_user_defined_p (op, arg1, arg2)) @@ -2572,7 +2574,7 @@ } else { - if (ptrmath_type_p (value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, value_type (arg1))) arg2 = value_ptradd (arg1, 1); else { @@ -2595,7 +2597,7 @@ } else { - if (ptrmath_type_p (value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, value_type (arg1))) arg2 = value_ptradd (arg1, -1); else { @@ -2618,7 +2620,7 @@ } else { - if (ptrmath_type_p (value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, value_type (arg1))) arg2 = value_ptradd (arg1, 1); else { @@ -2642,7 +2644,7 @@ } else { - if (ptrmath_type_p (value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, value_type (arg1))) arg2 = value_ptradd (arg1, -1); else { @@ -2832,7 +2834,7 @@ var = exp->elts[pc + 2].symbol; type = check_typedef (SYMBOL_TYPE (var)); if (TYPE_CODE (type) == TYPE_CODE_ARRAY - && CAST_IS_CONVERSION) + && CAST_IS_CONVERSION (exp->language_defn)) { (*pos) += 4; val = address_of_variable (var, exp->elts[pc + 1].block); Index: language.h =================================================================== RCS file: /cvs/src/src/gdb/language.h,v retrieving revision 1.65 diff -u -r1.65 language.h --- language.h 2 May 2010 21:14:59 -0000 1.65 +++ language.h 10 May 2010 19:42:47 -0000 @@ -381,9 +381,9 @@ /* "cast" really means conversion */ /* FIXME -- should be a setting in language_defn */ -#define CAST_IS_CONVERSION (current_language->la_language == language_c || \ - current_language->la_language == language_cplus || \ - current_language->la_language == language_objc) +#define CAST_IS_CONVERSION(LANG) ((LANG)->la_language == language_c || \ + (LANG)->la_language == language_cplus || \ + (LANG)->la_language == language_objc) extern void language_info (int);