From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6545 invoked by alias); 26 Jun 2009 15:53:59 -0000 Received: (qmail 6534 invoked by uid 22791); 26 Jun 2009 15:53:58 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate2.de.ibm.com (HELO mtagate2.de.ibm.com) (195.212.17.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Jun 2009 15:53:50 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id n5QFrmdJ008831 for ; Fri, 26 Jun 2009 15:53:48 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.2) with ESMTP id n5QFrlwd3891446 for ; Fri, 26 Jun 2009 17:53:47 +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 n5QFrl3O030417 for ; Fri, 26 Jun 2009 17:53:47 +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 SMTP id n5QFrkps030405; Fri, 26 Jun 2009 17:53:46 +0200 Message-Id: <200906261553.n5QFrkps030405@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 26 Jun 2009 17:53:46 +0200 Subject: [rfa/Ada] Remove builtin_type_void To: brobecker@adacore.com, gdb-patches@sourceware.org Date: Fri, 26 Jun 2009 15:53:00 -0000 From: "Ulrich Weigand" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2009-06/txt/msg00720.txt.bz2 Hello Joel, this patch removes references to builtin_type_void from Ada code. The only nontrivial case is the use in ada_resolve_function. This routine is called with "context_type" either NULL or a void type on input. It implements a two-phase search, where in the first phase it accepts all routine with matching return type: If CONTEXT_TYPE is non-null and there is at least one match that returns that type, then eliminate matches that don't. If CONTEXT_TYPE is void and there is at least one match that does not return void, eliminate all matches that do. If no match is found during the first phase, it performs a second phase with an "inverted" value of context_type: if it was a void type, it becomes NULL, and if it was NULL, it becomes builtin_type_void. My patch simplifies this by having the second phase simply accept *all* matches. There is no need to "invert" context_type -- we already know that there are no matches for context_type, so any remaining match is OK to return. Tested on amd64-linux. OK for mainline? Bye, Ulrich ChangeLog: * ada-lang.c (resolve): Use per-architecture void type instead of platform-independent one. (ada_evaluate_subexp) [STRUCTOP_STRUCT]: Likewise. (ada_resolve_function): Reimplement fallback logic to avoid explicit reference to builtin_type_void. Index: gdb-head/gdb/ada-lang.c =================================================================== --- gdb-head.orig/gdb/ada-lang.c +++ gdb-head/gdb/ada-lang.c @@ -2583,9 +2583,13 @@ ada_decoded_op_name (enum exp_opcode op) static void resolve (struct expression **expp, int void_context_p) { - int pc; - pc = 0; - resolve_subexp (expp, &pc, 1, void_context_p ? builtin_type_void : NULL); + struct type *context_type = NULL; + int pc = 0; + + if (void_context_p) + context_type = builtin_type ((*expp)->gdbarch)->builtin_void; + + resolve_subexp (expp, &pc, 1, context_type); } /* Resolve the operator of the subexpression beginning at @@ -3091,35 +3095,27 @@ ada_resolve_function (struct ada_symbol_ int nsyms, struct value **args, int nargs, const char *name, struct type *context_type) { + int fallback; int k; int m; /* Number of hits */ - struct type *fallback; - struct type *return_type; - - return_type = context_type; - if (context_type == NULL) - fallback = builtin_type_void; - else - fallback = NULL; m = 0; - while (1) + /* In the first pass of the loop, we only accept functions matching + context_type. If none are found, we add a second pass of the loop + where every function is accepted. */ + for (fallback = 0; m == 0 && fallback < 2; fallback++) { for (k = 0; k < nsyms; k += 1) { struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].sym)); if (ada_args_match (syms[k].sym, args, nargs) - && return_match (type, return_type)) + && (fallback || return_match (type, context_type))) { syms[m] = syms[k]; m += 1; } } - if (m > 0 || return_type == fallback) - break; - else - return_type = fallback; } if (m == 0) @@ -9372,7 +9368,8 @@ ada_evaluate_subexp (struct type *expect in some extension of the type. Return an object of "type" void, which will match any formal (see ada_type_match). */ - return value_zero (builtin_type_void, lval_memory); + return value_zero (builtin_type (exp->gdbarch)->builtin_void, + lval_memory); } else type = -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com