From patchwork Tue Apr 5 11:25:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 89815 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 A3518B6F8C for ; Tue, 5 Apr 2011 21:26:05 +1000 (EST) Received: (qmail 28457 invoked by alias); 5 Apr 2011 11:26:03 -0000 Received: (qmail 28441 invoked by uid 22791); 5 Apr 2011 11:26:02 -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; Tue, 05 Apr 2011 11:25:58 +0000 Received: (qmail 433 invoked from network); 5 Apr 2011 11:25:57 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 5 Apr 2011 11:25:57 -0000 Date: Tue, 5 Apr 2011 07:25:52 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] don't use TYPE_ARG_TYPES in type_generic or sentinel attribute handling Message-ID: <20110405112551.GA4382@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-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 The type_generic and sentinel attribute handlers for c-family, LTO, and Ada grovel through TYPE_ARG_TYPES; this patch changes them to use the standard functions prototype_p and stdarg_p instead. Less TYPE_ARG_TYPES usage is a good thing. The prototype_p check in the type_generic handlers is gross, but it's necessary with the current system, because we have functions like: DEF_GCC_BUILTIN (BUILT_IN_ISFINITE, "isfinite", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF) i.e. a zero-argument, "varargs" function. Better would be to have a flag in FUNCTION_TYPE denoting vararg-ness, rather than the void_list_node vs. NULL scheme we have now, but that's further down the line. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan gcc/ada/ * gcc-interface/utils.c (handle_sentinel_attribute): Don't use TYPE_ARG_TYPES (handle_type_generic_attribute): Likewise. gcc/c-family/ * c-common.c (handle_sentinel_attribute): Don't use TYPE_ARG_TYPES. (handle_type_generic_attribute): Likewise. gcc/lto/ * lto-lang.c (handle_sentinel_attribute): Don't use TYPE_ARG_TYPES. (handle_type_generic_attribute): Likewise. diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index dc74374..8a78789 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -5266,8 +5266,6 @@ static tree handle_sentinel_attribute (tree *node, tree name, tree args, int ARG_UNUSED (flags), bool *no_add_attrs) { - tree params = TYPE_ARG_TYPES (*node); - if (!prototype_p (*node)) { warning (OPT_Wattributes, @@ -5277,10 +5275,7 @@ handle_sentinel_attribute (tree *node, tree name, tree args, } else { - while (TREE_CHAIN (params)) - params = TREE_CHAIN (params); - - if (VOID_TYPE_P (TREE_VALUE (params))) + if (!stdarg_p (*node)) { warning (OPT_Wattributes, "%qs attribute only applies to variadic functions", @@ -5400,17 +5395,11 @@ handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name), tree ARG_UNUSED (args), int ARG_UNUSED (flags), bool * ARG_UNUSED (no_add_attrs)) { - tree params; - /* Ensure we have a function type. */ gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE); - params = TYPE_ARG_TYPES (*node); - while (params && ! VOID_TYPE_P (TREE_VALUE (params))) - params = TREE_CHAIN (params); - /* Ensure we have a variadic function. */ - gcc_assert (!params); + gcc_assert (!prototype_p (*node) || stdarg_p (*node)); return NULL_TREE; } diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index cab9e7e..1d40292 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -7653,8 +7653,6 @@ static tree handle_sentinel_attribute (tree *node, tree name, tree args, int ARG_UNUSED (flags), bool *no_add_attrs) { - tree params = TYPE_ARG_TYPES (*node); - if (!prototype_p (*node)) { warning (OPT_Wattributes, @@ -7663,10 +7661,7 @@ handle_sentinel_attribute (tree *node, tree name, tree args, } else { - while (TREE_CHAIN (params)) - params = TREE_CHAIN (params); - - if (VOID_TYPE_P (TREE_VALUE (params))) + if (!stdarg_p (*node)) { warning (OPT_Wattributes, "%qE attribute only applies to variadic functions", name); @@ -7705,17 +7700,11 @@ handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name), tree ARG_UNUSED (args), int ARG_UNUSED (flags), bool * ARG_UNUSED (no_add_attrs)) { - tree params; - /* Ensure we have a function type. */ gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE); - params = TYPE_ARG_TYPES (*node); - while (params && ! VOID_TYPE_P (TREE_VALUE (params))) - params = TREE_CHAIN (params); - /* Ensure we have a variadic function. */ - gcc_assert (!params); + gcc_assert (!prototype_p (*node) || stdarg_p (*node)); return NULL_TREE; } diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index 535fc58..c65d916 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -373,13 +373,7 @@ handle_sentinel_attribute (tree *node, tree ARG_UNUSED (name), tree args, int ARG_UNUSED (flags), bool * ARG_UNUSED (no_add_attrs)) { - tree params = TYPE_ARG_TYPES (*node); - gcc_assert (params); - - while (TREE_CHAIN (params)) - params = TREE_CHAIN (params); - - gcc_assert (!VOID_TYPE_P (TREE_VALUE (params))); + gcc_assert (stdarg_p (*node)); if (args) { @@ -399,17 +393,11 @@ handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name), tree ARG_UNUSED (args), int ARG_UNUSED (flags), bool * ARG_UNUSED (no_add_attrs)) { - tree params; - /* Ensure we have a function type. */ gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE); - params = TYPE_ARG_TYPES (*node); - while (params && ! VOID_TYPE_P (TREE_VALUE (params))) - params = TREE_CHAIN (params); - /* Ensure we have a variadic function. */ - gcc_assert (!params); + gcc_assert (!prototype_p (*node) || stdarg_p (*node)); return NULL_TREE; }