From patchwork Wed May 4 03:54:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 93969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D3D38B6F70 for ; Wed, 4 May 2011 13:55:11 +1000 (EST) Received: (qmail 502 invoked by alias); 4 May 2011 03:54:53 -0000 Received: (qmail 487 invoked by uid 22791); 4 May 2011 03:54:51 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 May 2011 03:54:35 +0000 Received: (qmail 20423 invoked from network); 4 May 2011 03:54:34 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 4 May 2011 03:54:34 -0000 Date: Tue, 3 May 2011 20:54:34 -0700 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] don't use TYPE_ARG_TYPES in the Ada FE Message-ID: <20110504035434.GE23480@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org As $SUBJECT suggests; the patch makes the Ada FE use iterators instead. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan * gcc-interface/decl.c (intrin_arglists_compatible_p): Use iterators instead of accessing TYPE_ARG_TYPES directly. * gcc-interface/utils.c (handle_nonnull_attribute): Likewise. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 14929b8..2a55940 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -8331,23 +8331,27 @@ intrin_types_incompatible_p (tree t1, tree t2) static bool intrin_arglists_compatible_p (intrin_binding_t * inb) { - tree ada_args = TYPE_ARG_TYPES (inb->ada_fntype); - tree btin_args = TYPE_ARG_TYPES (inb->btin_fntype); + function_args_iterator ada_iter, btin_iter; + + function_args_iter_init (&ada_iter, inb->ada_fntype); + function_args_iter_init (&btin_iter, inb->btin_fntype); /* Sequence position of the last argument we checked. */ int argpos = 0; - while (ada_args != 0 || btin_args != 0) + while (1) { - tree ada_type, btin_type; + tree ada_type = function_args_iter_cond (&ada_iter); + tree btin_type = function_args_iter_cond (&btin_iter); + + /* If we've exhausted both lists simultaneously, we're done. */ + if (ada_type == NULL_TREE && btin_type == NULL_TREE) + break; /* If one list is shorter than the other, they fail to match. */ - if (ada_args == 0 || btin_args == 0) + if (ada_type == NULL_TREE || btin_type == NULL_TREE) return false; - ada_type = TREE_VALUE (ada_args); - btin_type = TREE_VALUE (btin_args); - /* If we're done with the Ada args and not with the internal builtin args, or the other way around, complain. */ if (ada_type == void_type_node @@ -8374,8 +8378,9 @@ intrin_arglists_compatible_p (intrin_binding_t * inb) return false; } - ada_args = TREE_CHAIN (ada_args); - btin_args = TREE_CHAIN (btin_args); + + function_args_iter_next (&ada_iter); + function_args_iter_next (&btin_iter); } return true; diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 2e81c18..2b29748 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -5219,7 +5219,6 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name), a pointer argument. */ for (attr_arg_num = 1; args; args = TREE_CHAIN (args)) { - tree argument; unsigned HOST_WIDE_INT arg_num = 0, ck_num; if (!get_nonnull_operand (TREE_VALUE (args), &arg_num)) @@ -5230,18 +5229,21 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name), return NULL_TREE; } - argument = TYPE_ARG_TYPES (type); - if (argument) + if (prototype_p (type)) { - for (ck_num = 1; ; ck_num++) + function_args_iterator iter; + tree argument; + + function_args_iter_init (&iter, type); + for (ck_num = 1; ; ck_num++, function_args_iter_next (&iter)) { + argument = function_args_iter_cond (&iter); if (!argument || ck_num == arg_num) break; - argument = TREE_CHAIN (argument); } if (!argument - || TREE_CODE (TREE_VALUE (argument)) == VOID_TYPE) + || TREE_CODE (argument) == VOID_TYPE) { error ("nonnull argument with out-of-range operand number " "(argument %lu, operand %lu)", @@ -5250,7 +5252,7 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name), return NULL_TREE; } - if (TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE) + if (TREE_CODE (argument) != POINTER_TYPE) { error ("nonnull argument references non-pointer operand " "(argument %lu, operand %lu)",