From patchwork Sat Nov 18 02:52:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467248-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HlxWwS9A"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzxv0wd1z9s72 for ; Sat, 18 Nov 2017 13:50:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=KK4jzpxPNNmH+Ood0CL3sd8fjZqTMyLXgTM2CkbzrmcsL+fKs9kka 6GbNyicUMYRdUBmXVJc+evpIZvccHDdEiHwLbd6Dvj62LgrxeD7g3+wJFTq4HxKS yxLu7KzRpuUSHU1n+eNFtFs3zkwzXnpOcjX7uIqbsgMLiHxdFvsHdQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=98b4itBEFGC1NIJ2TDUVHbD0UYg=; b=HlxWwS9AkF/b+vQ02ulA Sj9pRtl7j1vPpMdOQbNPMaS13Py8hM6b6BoBNgMPXG+qF0Hd+972b2mf+D/vyGDD OgUs+r5z5WL3R2l0Ged/7ySZoVsQ3nFkV/HWcmSP6wVdM5DOYxGY7fQhy7wgGVmB +RQwtwLzjrrquvdtvdg1IYY= Received: (qmail 67337 invoked by alias); 18 Nov 2017 02:50:42 -0000 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 Received: (qmail 67216 invoked by uid 89); 18 Nov 2017 02:50:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=idk, LOCATION, va_gc X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:40 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A37CC049D5F; Sat, 18 Nov 2017 02:50:38 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1DF060BF3; Sat, 18 Nov 2017 02:50:36 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 01/11] C++: Add location wrappers for all constants and decls Date: Fri, 17 Nov 2017 21:52:33 -0500 Message-Id: <1510973563-10046-2-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes This redoes the approach in the v1 patch, doing it for all constants and decls, rather than just at callsite args. gcc/cp/ChangeLog: * parser.c (cp_parser_primary_expression): Add location wrappers to constants. (cp_parser_postfix_expression): Remove the "wrap_locations_p" param to cp_parser_parenthesized_expression_list from the earlier patch. (cp_parser_parenthesized_expression_list): Likewise; don't add location wrappers. * semantics.c (finish_id_expression): Rename to... (finish_id_expression_1): ...this. (finish_id_expression): Reintroduce, wrapping the result in a location wrapper, if necessary. --- gcc/cp/parser.c | 29 ++++++++++++---------------- gcc/cp/semantics.c | 56 ++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 15489c1..8834542 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2054,8 +2054,7 @@ static tree cp_parser_postfix_open_square_expression static tree cp_parser_postfix_dot_deref_expression (cp_parser *, enum cpp_ttype, cp_expr, bool, cp_id_kind *, location_t); static vec *cp_parser_parenthesized_expression_list - (cp_parser *, int, bool, bool, bool *, location_t * = NULL, - bool = false); + (cp_parser *, int, bool, bool, bool *, location_t * = NULL); /* Values for the second parameter of cp_parser_parenthesized_expression_list. */ enum { non_attr = 0, normal_attr = 1, id_attr = 2 }; static void cp_parser_pseudo_destructor_name @@ -5066,7 +5065,8 @@ cp_parser_primary_expression (cp_parser *parser, if (!cast_p) cp_parser_non_integral_constant_expression (parser, NIC_FLOAT); } - return cp_expr (token->u.value, token->location); + return (cp_expr (token->u.value, token->location) + .maybe_add_location_wrapper ()); case CPP_CHAR_USERDEF: case CPP_CHAR16_USERDEF: @@ -5088,9 +5088,10 @@ cp_parser_primary_expression (cp_parser *parser, /* ??? Should wide strings be allowed when parser->translate_strings_p is false (i.e. in attributes)? If not, we can kill the third argument to cp_parser_string_literal. */ - return cp_parser_string_literal (parser, - parser->translate_strings_p, - true); + return (cp_parser_string_literal (parser, + parser->translate_strings_p, + true) + .maybe_add_location_wrapper ()); case CPP_OPEN_PAREN: /* If we see `( { ' then we are looking at the beginning of @@ -7099,8 +7100,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, (parser, non_attr, /*cast_p=*/false, /*allow_expansion_p=*/true, /*non_constant_p=*/NULL, - /*close_paren_loc=*/&close_paren_loc, - /*wrap_locations_p=*/true)); + /*close_paren_loc=*/&close_paren_loc)); if (is_builtin_constant_p) { parser->integral_constant_expression_p @@ -7764,8 +7764,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, bool cast_p, bool allow_expansion_p, bool *non_constant_p, - location_t *close_paren_loc, - bool wrap_locations_p) + location_t *close_paren_loc) { vec *expression_list; bool fold_expr_p = is_attribute_list != non_attr; @@ -7788,12 +7787,12 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, = parser->greater_than_is_operator_p; parser->greater_than_is_operator_p = true; - cp_expr expr (NULL_TREE); - /* Consume expressions until there are no more. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)) while (true) { + tree expr; + /* At the beginning of attribute lists, check to see if the next token is an identifier. */ if (is_attribute_list == id_attr @@ -7847,15 +7846,11 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, expr = make_pack_expansion (expr); } - if (wrap_locations_p) - if (!processing_template_decl) - expr.maybe_add_location_wrapper (); - /* Add it to the list. We add error_mark_node expressions to the list, so that we can still tell if the correct form for a parenthesized expression-list is found. That gives better errors. */ - vec_safe_push (expression_list, expr.get_value ()); + vec_safe_push (expression_list, expr); if (expr == error_mark_node) goto skip_comma; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 51489d1..dfdc458 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3453,20 +3453,20 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use) the use of "this" explicit. Upon return, *IDK will be filled in appropriately. */ -cp_expr -finish_id_expression (tree id_expression, - tree decl, - tree scope, - cp_id_kind *idk, - bool integral_constant_expression_p, - bool allow_non_integral_constant_expression_p, - bool *non_integral_constant_expression_p, - bool template_p, - bool done, - bool address_p, - bool template_arg_p, - const char **error_msg, - location_t location) +static cp_expr +finish_id_expression_1 (tree id_expression, + tree decl, + tree scope, + cp_id_kind *idk, + bool integral_constant_expression_p, + bool allow_non_integral_constant_expression_p, + bool *non_integral_constant_expression_p, + bool template_p, + bool done, + bool address_p, + bool template_arg_p, + const char **error_msg, + location_t location) { decl = strip_using_decl (decl); @@ -3766,6 +3766,34 @@ finish_id_expression (tree id_expression, return cp_expr (decl, location); } +/* As per finish_id_expression_1, but adding a wrapper node + around the result if needed to express LOCATION. */ + +cp_expr +finish_id_expression (tree id_expression, + tree decl, + tree scope, + cp_id_kind *idk, + bool integral_constant_expression_p, + bool allow_non_integral_constant_expression_p, + bool *non_integral_constant_expression_p, + bool template_p, + bool done, + bool address_p, + bool template_arg_p, + const char **error_msg, + location_t location) +{ + cp_expr result + = finish_id_expression_1 (id_expression, decl, scope, idk, + integral_constant_expression_p, + allow_non_integral_constant_expression_p, + non_integral_constant_expression_p, + template_p, done, address_p, template_arg_p, + error_msg, location); + return result.maybe_add_location_wrapper (); +} + /* Implement the __typeof keyword: Return the type of EXPR, suitable for use as a type-specifier. */ From patchwork Sat Nov 18 02:52:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467249-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="se/42Xmv"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzy71LBzz9s72 for ; Sat, 18 Nov 2017 13:51:11 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=l7+hhVzOCwE9gp9h2tn+YXoqgWHO6aKsCrK1sikR6yUvSCjLbkutg F1qJdiMjg8ScxAH1op/mOw1hYLiznh5XPcHYGXr0JtSyKS/yNEtht/5FKddrdeg+ Nu58umrVaQ7OBNM+z+/i2lzHVcaNOEhsn+Ybdkj5UAewo0yMZtdxhk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=NcbcIoO+Mf2B628uvxDCJNbWERI=; b=se/42Xmvgwss86zkdUL+ PuA0aOBDlMlYa4WzUJHgAAdUhqBRyBFXZwr0k85yiJN3j711tArTNQy/mVKqleYL nKLF9ojwrqHbm+TSOR6wnRRVNux588zwnUAkfZaFqM7Toe7kn+kvR2ixnAsJQS9p bvwyhbEOS0ZJSK03ezCQG8k= Received: (qmail 67496 invoked by alias); 18 Nov 2017 02:50:43 -0000 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 Received: (qmail 67432 invoked by uid 89); 18 Nov 2017 02:50:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1201 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:41 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7008F7EBD6; Sat, 18 Nov 2017 02:50:40 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4DD76A025; Sat, 18 Nov 2017 02:50:38 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 02/11] cp_tree::maybe_add_location_wrapper: no-op for template decls Date: Fri, 17 Nov 2017 21:52:34 -0500 Message-Id: <1510973563-10046-3-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes For simplicity, add a gate on !processing_template_decl to cp_tree::maybe_add_location_wrapper. gcc/cp/ChangeLog: * cp-tree.h (cp_expr::maybe_add_location_wrapper): Do nothing if processing_template_decl. --- gcc/cp/cp-tree.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 03087f0..63e9bff 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -93,11 +93,7 @@ public: set_location (make_location (m_loc, start, finish)); } - cp_expr& maybe_add_location_wrapper () - { - m_value = maybe_wrap_with_location (m_value, m_loc); - return *this; - } + cp_expr& maybe_add_location_wrapper (); private: tree m_value; @@ -1642,6 +1638,16 @@ struct warning_sentinel ~warning_sentinel() { flag = val; } }; +inline cp_expr& +cp_expr::maybe_add_location_wrapper () +{ + /* For now, don't add wrappers when processing template decls. */ + if (!processing_template_decl) + m_value = maybe_wrap_with_location (m_value, m_loc); + return *this; +} + + /* The cached class binding level, from the most recently exited class, or NULL if none. */ From patchwork Sat Nov 18 02:52:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467250-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Woe8mcBW"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzyK6Kgbz9s72 for ; Sat, 18 Nov 2017 13:51:21 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=GVlH25FSNzbot/ofGt5VN9vmpBE9Bqygb/zCddl/4f/kXhQS8QbYS rtNKFxx5/54Yi0sixmXuCczgqF2q/xWyXEJ7FUl8yIbuuZEx54FL4PcBcrRKzxus z3754eORwJHSJjFML3AOeYorfBrjFq1/VTufDQ5zs74J5oiocCmYQg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=37DYvtUlsNxsgAy7YZvfhVtWPpY=; b=Woe8mcBWnM1PTiAyYt1V sSiazB+NVSD7PJxrCSnydb7KCpALXKdin9GD3OPQetLKo4LmbXv3YjyEqZq9FvZ8 Ht6CrmUtpAieZwuiK8rCAlP+b1FQm58PfVd0H6XschvCU3J5sL8nFj4BkLY018qk eKzNdyx7714mS504mu2QuM8= Received: (qmail 68129 invoked by alias); 18 Nov 2017 02:50:48 -0000 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 Received: (qmail 67999 invoked by uid 89); 18 Nov 2017 02:50:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:913 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:46 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11BF3C0587CD; Sat, 18 Nov 2017 02:50:45 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84B5460BF3; Sat, 18 Nov 2017 02:50:40 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 03/11] Implement STRIP_ANY_LOCATION_WRAPPER_SAFE Date: Fri, 17 Nov 2017 21:52:35 -0500 Message-Id: <1510973563-10046-4-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes We occasionally need to handle the NULL case when stripping trees, so this patch introduces a variant of STRIP_ANY_LOCATION_WRAPPER to do so. gcc/ChangeLog: * tree.h (STRIP_ANY_LOCATION_WRAPPER_SAFE): New macro. --- gcc/tree.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/tree.h b/gcc/tree.h index 9a0bd60..98acc8b 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -492,6 +492,14 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, (EXP) = TREE_OPERAND ((EXP), 0); \ } while (0) +/* As STRIP_ANY_LOCATION_WRAPPER, but handle NULL_TREE. */ + +#define STRIP_ANY_LOCATION_WRAPPER_SAFE(EXP) \ + do { \ + if ((EXP) && location_wrapper_p (EXP)) \ + (EXP) = TREE_OPERAND ((EXP), 0); \ + } while (0) + /* Nonzero if TYPE represents a vector type. */ #define VECTOR_TYPE_P(TYPE) (TREE_CODE (TYPE) == VECTOR_TYPE) From patchwork Sat Nov 18 02:52:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467251-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GuTOmerF"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzyX5RPJz9s72 for ; Sat, 18 Nov 2017 13:51:32 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=Wa2E6mE+XEyIBeg7J1tR/k4m2WQv0RaEU4nVhZLwp0wIRpcyAuNHE PJRCtxVIsOBf4dlCKYYBPD2LAyrqKcKqjDEJCJ2sLwSUxpinW7RXS+KE3+4tjTqF trI1auUmvh4iGpXwXuMX+/xM7/6nTnA7/39sofblc+5rYZAX3S4YC4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=he5dJopFvHY1/1jk9WSi28ckSro=; b=GuTOmerFoHez89mXJ/lt MIvgIj9zH6t3qOig3uwuDUqwgep0SIpZbIxiOqSN3YYBuEvVzF/Z7ccvWF+lOLuA stWFrPv2jsytZHQLU9QsxjXLgyEJEGxEV9qwskadu3qPfK5ER4GjWLPAXuillrcj i/BWBDL8Sp+qvMLbu1PJe8E= Received: (qmail 68351 invoked by alias); 18 Nov 2017 02:50:49 -0000 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 Received: (qmail 68270 invoked by uid 89); 18 Nov 2017 02:50:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:588 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:48 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA2DF61BB4; Sat, 18 Nov 2017 02:50:46 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BD9B6A025; Sat, 18 Nov 2017 02:50:45 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 04/11] C++: add cp_expr::strip_any_location_wrapper method Date: Fri, 17 Nov 2017 21:52:36 -0500 Message-Id: <1510973563-10046-5-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes This is needed by perform_koenig_lookup. gcc/cp/ChangeLog: * cp-tree.h (cp_expr::strip_any_location_wrapper): New method. --- gcc/cp/cp-tree.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 63e9bff..f9c589d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -95,6 +95,11 @@ public: cp_expr& maybe_add_location_wrapper (); + void strip_any_location_wrapper () + { + STRIP_ANY_LOCATION_WRAPPER (m_value); + } + private: tree m_value; location_t m_loc; From patchwork Sat Nov 18 02:52:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467252-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="iDh1Ocw1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzym5RH6z9s72 for ; Sat, 18 Nov 2017 13:51:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=UO1jxPPtzJ1lP/Oi7FNmT9VjiX8scth0r5C40HcVEaD/wZlM5nuT+ BPKQLzw/4vqQ+0biN4G1e1UfDjBZ9p7JD2y+GwZstbU4kI+xWRL7nqxUM6pxX3DU S1hQ8LcKnVZyPIulQOxx9+LmwTF3FkUFl6x5dEhBDDDf2Nurzce7yA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=FKrY0Q+dAWsMNmlthGxMCbmXZE4=; b=iDh1Ocw15GUPgglGwsEu zJcbvuoF0qgnaVv7BHWybnfLgc5ljaSPx1ulrVctt70iia7EG/9HGYDaZplxt1LP /lW2+rQE4Qz5+FS2IOheCcm1B1O15rtlNiKc8UNBJEWqjYa16LsQa20SKN4489X3 yKwbcKV6vSOaeFGUc/7wAac= Received: (qmail 68595 invoked by alias); 18 Nov 2017 02:50:51 -0000 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 Received: (qmail 68538 invoked by uid 89); 18 Nov 2017 02:50:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:822 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:50 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EED2EC04AC42; Sat, 18 Nov 2017 02:50:48 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5039060BF3; Sat, 18 Nov 2017 02:50:47 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 05/11] C++: finish_call_expr: strip location wrapper Date: Fri, 17 Nov 2017 21:52:37 -0500 Message-Id: <1510973563-10046-6-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes This is needed to recognize calls to known functions, otherwise such calls get erroneously handled by cp_build_function_call_vec. gcc/cp/ChangeLog: * semantics.c (finish_call_expr): Strip any location wrapper from fn. --- gcc/cp/semantics.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index dfdc458..f292d17 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2314,6 +2314,8 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, gcc_assert (!TYPE_P (fn)); + STRIP_ANY_LOCATION_WRAPPER (fn); + /* If FN may be a FUNCTION_DECL obfuscated by force_paren_expr, undo it so that we can tell this is a call to a known function. */ fn = maybe_undo_parenthesized_ref (fn); From patchwork Sat Nov 18 02:52:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467253-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Bd4SL69u"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzyy0dT8z9s72 for ; Sat, 18 Nov 2017 13:51:53 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=GyeapuMikma+oKXVfcKP/rFo4kHA1aDIX8WAI6ofHq/zjyXfw+rdy ofuB3Oi3/Z3dd/uCBo2p5GvNiuZuIZYl+/jPvs6YZDBHrmbUBKmZaTASWMILtiAi uE1zKNJt0wzP03J1KDfy1Grz9DHRAnd3Zk0zYloNnf7LtBC+LdWy7Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=Dbbsdf9t3J8vxwkzAIqzUconYtg=; b=Bd4SL69ulArKw4wwuoEI WuPXo2DTBm2L3p4NmEoLm5KfXMwkn6Bcq3KeNbbYLLzhTDFDvqGSQ7m+QmE2yhmS BuP+3Pp97JGVWCNllBSdPp6/FN5fzfLpE82mxdV5AW2SO7xx++CEzi7dVP3FPy12 ++/4MWPmowT4ap/RmcoJESw= Received: (qmail 68884 invoked by alias); 18 Nov 2017 02:50:53 -0000 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 Received: (qmail 68833 invoked by uid 89); 18 Nov 2017 02:50:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:52 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F395F7E430; Sat, 18 Nov 2017 02:50:50 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 564976A025; Sat, 18 Nov 2017 02:50:49 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 06/11] gcc: Handle location wrappers in operand_equal_p Date: Fri, 17 Nov 2017 21:52:38 -0500 Message-Id: <1510973563-10046-7-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes Fixes e.g. c-c++-common/Wsizeof-pointer-memaccess1.c gcc/ChangeLog: * fold-const.c (operand_equal_p): Handle location wrappers. * tree.c (inchash::add_expr): Likewise. --- gcc/fold-const.c | 3 +++ gcc/tree.c | 1 + 2 files changed, 4 insertions(+) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e9cd968..ababa68 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2802,6 +2802,9 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) != TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (arg1))))) return 0; + STRIP_ANY_LOCATION_WRAPPER (arg0); + STRIP_ANY_LOCATION_WRAPPER (arg1); + /* Check equality of integer constants before bailing out due to precision differences. */ if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST) diff --git a/gcc/tree.c b/gcc/tree.c index f71b484..6ef290d 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7092,6 +7092,7 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags) if (!(flags & OEP_ADDRESS_OF)) STRIP_NOPS (t); + STRIP_ANY_LOCATION_WRAPPER (t); code = TREE_CODE (t); From patchwork Sat Nov 18 02:52:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467254-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SXYxRsHY"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzz83lF3z9s72 for ; Sat, 18 Nov 2017 13:52:04 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=mxhEU3t1yMHmJIhAa1He7Qhh19z75K7T81u9/qFgh86uf76NMU7WQ hUj9aNxvSUlSj9vBp/DjXANmE074n82A+iE6B+K1servMIkxPgKpxxMkQZW9IEBi egE4TAlfLi/bC4DH8lvvAsCoY8nrrHiUjs0jL3xpFgzFRvgXQHLxUw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=lj/ctmdPv1hhrpaplHIy7YNGh5Y=; b=SXYxRsHYJPloUFbX7zA6 7eKdWSy94qT8zP2bZt7VDWFuAPjFhyisg9bzjIBlY/CDkPigYd++5f8cI0AM/9VN VkDayM/RKE1B59ZiHNwNrK75nNjr/zXMRpbkiiq9BFoBbomw4+XKG31YDN03nrSe mhEKVH9r6zX2Blotw11JzhY= Received: (qmail 69212 invoked by alias); 18 Nov 2017 02:50:56 -0000 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 Received: (qmail 69164 invoked by uid 89); 18 Nov 2017 02:50:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=2636 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:54 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0461CFC7CE; Sat, 18 Nov 2017 02:50:53 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 598A060DCE; Sat, 18 Nov 2017 02:50:51 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 07/11] c-family: handle location wrappers Date: Fri, 17 Nov 2017 21:52:39 -0500 Message-Id: <1510973563-10046-8-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes gcc/c-family/ChangeLog: * c-attribs.c (handle_tm_wrap_attribute): Handle location wrappers. * c-common.c (c_common_truthvalue_conversion): Likewise. (check_user_alignment): Likewise. (get_nonnull_operand): Likewise. (fold_offsetof_1): Likewise. (convert_vector_to_array_for_subscript): Likewise. * c-format.c (get_constant): Likewise. * c-warn.c (warn_logical_operator): Likewise. (find_array_ref_with_const_idx_r): Likewise. (warn_array_subscript_with_type_char): Likewise. --- gcc/c-family/c-attribs.c | 1 + gcc/c-family/c-common.c | 9 +++++++++ gcc/c-family/c-format.c | 2 ++ gcc/c-family/c-warn.c | 25 +++++++++++++++++-------- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index bb75cba..e757628 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -2762,6 +2762,7 @@ handle_tm_wrap_attribute (tree *node, tree name, tree args, else { tree wrap_decl = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER_SAFE (wrap_decl); if (error_operand_p (wrap_decl)) ; else if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 5a26424..59a4d93 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3228,6 +3228,8 @@ decl_with_nonnull_addr_p (const_tree expr) tree c_common_truthvalue_conversion (location_t location, tree expr) { + STRIP_ANY_LOCATION_WRAPPER (expr); + switch (TREE_CODE (expr)) { case EQ_EXPR: case NE_EXPR: case UNEQ_EXPR: case LTGT_EXPR: @@ -5079,6 +5081,9 @@ check_user_alignment (const_tree align, bool allow_zero) if (error_operand_p (align)) return -1; + + STRIP_ANY_LOCATION_WRAPPER (align); + if (TREE_CODE (align) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (align))) { @@ -5356,6 +5361,8 @@ check_nonnull_arg (void *ctx, tree param, unsigned HOST_WIDE_INT param_num) bool get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp) { + STRIP_ANY_LOCATION_WRAPPER (arg_num_expr); + /* Verify the arg number is a small constant. */ if (tree_fits_uhwi_p (arg_num_expr)) { @@ -6155,6 +6162,7 @@ fold_offsetof_1 (tree expr, enum tree_code ctx) return base; t = TREE_OPERAND (expr, 1); + STRIP_ANY_LOCATION_WRAPPER (t); /* Check if the offset goes beyond the upper bound of the array. */ if (TREE_CODE (t) == INTEGER_CST && tree_int_cst_sgn (t) >= 0) @@ -7600,6 +7608,7 @@ convert_vector_to_array_for_subscript (location_t loc, ret = !lvalue_p (*vecp); + STRIP_ANY_LOCATION_WRAPPER (index); if (TREE_CODE (index) == INTEGER_CST) if (!tree_fits_uhwi_p (index) || tree_to_uhwi (index) >= TYPE_VECTOR_SUBPARTS (type)) diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 6b436ec..cdcd03a 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -263,6 +263,8 @@ check_format_string (tree fntype, unsigned HOST_WIDE_INT format_num, static bool get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p) { + STRIP_ANY_LOCATION_WRAPPER (expr); + if (!tree_fits_uhwi_p (expr)) { gcc_assert (!validated_p); diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 0086435..c7bc478 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -246,6 +246,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, lhs = make_range (op_left, &in0_p, &low0, &high0, &strict_overflow_p); if (!lhs) return; + STRIP_ANY_LOCATION_WRAPPER (lhs); /* If this is an OR operation, invert both sides; now, the result should be always false to get a warning. */ @@ -261,6 +262,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, rhs = make_range (op_right, &in1_p, &low1, &high1, &strict_overflow_p); if (!rhs) return; + STRIP_ANY_LOCATION_WRAPPER (rhs); /* If this is an OR operation, invert both sides; now, the result should be always false to get a warning. */ @@ -313,10 +315,14 @@ find_array_ref_with_const_idx_r (tree *expr_p, int *, void *) { tree expr = *expr_p; - if ((TREE_CODE (expr) == ARRAY_REF - || TREE_CODE (expr) == ARRAY_RANGE_REF) - && TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST) - return integer_type_node; + if (TREE_CODE (expr) == ARRAY_REF + || TREE_CODE (expr) == ARRAY_RANGE_REF) + { + tree index = TREE_OPERAND (expr, 1); + STRIP_ANY_LOCATION_WRAPPER (index); + if (TREE_CODE (index) == INTEGER_CST) + return integer_type_node; + } return NULL_TREE; } @@ -1643,10 +1649,13 @@ invalid_indirection_error (location_t loc, tree type, ref_operator errstring) void warn_array_subscript_with_type_char (location_t loc, tree index) { - if (TYPE_MAIN_VARIANT (TREE_TYPE (index)) == char_type_node - && TREE_CODE (index) != INTEGER_CST) - warning_at (loc, OPT_Wchar_subscripts, - "array subscript has type %"); + if (TYPE_MAIN_VARIANT (TREE_TYPE (index)) == char_type_node) + { + STRIP_ANY_LOCATION_WRAPPER (index); + if (TREE_CODE (index) != INTEGER_CST) + warning_at (loc, OPT_Wchar_subscripts, + "array subscript has type %"); + } } /* Implement -Wparentheses for the unexpected C precedence rules, to From patchwork Sat Nov 18 02:52:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467255-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="U/cBj8m3"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzzN3YRtz9ryr for ; Sat, 18 Nov 2017 13:52:16 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=pwyYTXgn1FmBI22ZjEuSsTx6vPpZQlbJ6aVp+7TwXSmq7E0PunAFl 8/kgkTOMK9t+CUP++7qzes8QRe4XadcbYivgb9xavd9CTwXVthwMScI1nSm/Ujxu dR4zNw4Xx3mN7tnOEXwwpwv9qqIEIPCr0CO8EGEb+Lo58zQcyYJyH0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=5wAcILBb+hUCWtaT95XpOEzv6Hg=; b=U/cBj8m3IDO0ps5Cg50p K0Pn6r35rIXZ6q60QIu90PlsPcYjLrG/O+DqPgVlRR1wAv4CbZlew+tFwmBIJUxL AhMvj3ynC1Zo5Q34n2Rb/GbewAZukE20eDGL4SmN0BQxbyldrFvKycymhB+r3Z4V TFhLJ57SaLfdjukVydvj3LE= Received: (qmail 69944 invoked by alias); 18 Nov 2017 02:51:02 -0000 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 Received: (qmail 69880 invoked by uid 89); 18 Nov 2017 02:51:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:58 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF4507E430; Sat, 18 Nov 2017 02:50:56 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5207060BF3; Sat, 18 Nov 2017 02:50:53 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 08/11] C++: handle location wrappers Date: Fri, 17 Nov 2017 21:52:40 -0500 Message-Id: <1510973563-10046-9-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes gcc/cp/ChangeLog: * call.c (build_conditional_expr_1): Handle location wrappers. (build_new_op_1): Likewise. * class.c (mark_or_check_attr_tags): Likewise. * constexpr.c (cxx_eval_constant_expression): Likewise. * cvt.c (ocp_convert): Likewise. * decl.c (reshape_init_r): Likewise. (cp_complete_array_type): Likewise. * expr.c (mark_discarded_use): Likewise. * lambda.c (build_capture_proxy): Likewise. * name-lookup.c (handle_namespace_attrs): Likewise. * parser.c (cp_parser_postfix_expression): Likewise when checking for calls to memset and for component lookups. (cp_parser_unary_expression): Likewise for immediate folding of negated constants. (cp_parser_template_argument): Likewise. (cp_parser_omp_for_incr): Likewise. (cp_parser_omp_for_loop_init): Likewise. (cp_parser_omp_declare_reduction_exprs): Likewise. (cp_parser_cilk_simd_linear): Likewise. * pt.c (convert_nontype_argument_function): Likewise. (convert_nontype_argument): Likewise. * semantics.c (finish_asm_stmt): Likewise. (perform_koenig_lookup): Likewise. (handle_omp_array_sections_1): Likewise. (handle_omp_array_sections): Likewise. (omp_reduction_lookup): Likewise. (finish_omp_for): Likewise. * tree.c (cp_stabilize_reference): Likewise. (builtin_valid_in_constant_expr_p): Likewise. (is_overloaded_fn): Likewise. (get_fns): Likewise. (check_abi_tag_args): Likewise. * typeck.c (cxx_sizeof_expr): Likewise. (cp_build_binary_op): Likewise. (cp_build_modify_expr): Likewise. (maybe_warn_about_returning_address_of_local): Likewise. * typeck2.c (cxx_incomplete_type_diagnostic): Likewise. (digest_init_r): Likewise. --- gcc/cp/call.c | 7 ++++++ gcc/cp/class.c | 1 + gcc/cp/constexpr.c | 1 + gcc/cp/cvt.c | 1 + gcc/cp/decl.c | 4 ++++ gcc/cp/expr.c | 2 ++ gcc/cp/lambda.c | 3 +++ gcc/cp/name-lookup.c | 1 + gcc/cp/parser.c | 65 +++++++++++++++++++++++++++++++++------------------- gcc/cp/pt.c | 10 +++++++- gcc/cp/semantics.c | 44 ++++++++++++++++++++++------------- gcc/cp/tree.c | 8 +++++++ gcc/cp/typeck.c | 25 +++++++++++++++++--- gcc/cp/typeck2.c | 4 ++++ 14 files changed, 133 insertions(+), 43 deletions(-) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c1b662f..82302b5 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4816,6 +4816,9 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, orig_arg2 = arg2; orig_arg3 = arg3; + STRIP_ANY_LOCATION_WRAPPER (arg2); + STRIP_ANY_LOCATION_WRAPPER (arg3); + if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (arg1))) { tree arg1_type = TREE_TYPE (arg1); @@ -5588,6 +5591,10 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, || error_operand_p (arg3)) return error_mark_node; + STRIP_ANY_LOCATION_WRAPPER_SAFE (arg1); + STRIP_ANY_LOCATION_WRAPPER_SAFE (arg2); + STRIP_ANY_LOCATION_WRAPPER_SAFE (arg3); + bool ismodop = code == MODIFY_EXPR; if (ismodop) { diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 586a32c..781594c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1377,6 +1377,7 @@ mark_or_check_attr_tags (tree attr, tree *tp, abi_tag_data *p, bool val) list = TREE_CHAIN (list)) { tree tag = TREE_VALUE (list); + STRIP_ANY_LOCATION_WRAPPER (tag); tree id = get_identifier (TREE_STRING_POINTER (tag)); if (tp) check_tag (tag, id, tp, p); diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index d6b6843..3122743 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3943,6 +3943,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, tree *jump_target) { constexpr_ctx new_ctx; + STRIP_ANY_LOCATION_WRAPPER (t); tree r = t; if (jump_target && *jump_target) diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index b3a6f69..fdc2b8d 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -766,6 +766,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags, the original value is within the range of the enumeration values. Otherwise, the resulting enumeration value is unspecified. */ + STRIP_ANY_LOCATION_WRAPPER (e); if ((complain & tf_warning) && TREE_CODE (e) == INTEGER_CST && ENUM_UNDERLYING_TYPE (type) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7e16f7b..9afce0a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5809,6 +5809,8 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p, if (error_operand_p (init)) return error_mark_node; + STRIP_ANY_LOCATION_WRAPPER (init); + if (first_initializer_p && !CP_AGGREGATE_TYPE_P (type) && has_designator_problem (d, complain)) return error_mark_node; @@ -8115,6 +8117,8 @@ cp_complete_array_type (tree *ptype, tree initial_value, bool do_default) int failure; tree type, elt_type; + STRIP_ANY_LOCATION_WRAPPER_SAFE (initial_value); + /* Don't get confused by a CONSTRUCTOR for some other type. */ if (initial_value && TREE_CODE (initial_value) == CONSTRUCTOR && !BRACE_ENCLOSED_INITIALIZER_P (initial_value) diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index 81b9a5b..07630fc 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -220,6 +220,8 @@ mark_discarded_use (tree expr) if (expr == NULL_TREE) return expr; + STRIP_ANY_LOCATION_WRAPPER (expr); + switch (TREE_CODE (expr)) { case COND_EXPR: diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 4480c67..c403a25 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -428,6 +428,8 @@ build_capture_proxy (tree member, tree init) TREE_USED (var) = 1; DECL_CONTEXT (var) = fn; + STRIP_ANY_LOCATION_WRAPPER (init); + if (DECL_NORMAL_CAPTURE_P (member)) { if (DECL_VLA_CAPTURE_P (member)) @@ -444,6 +446,7 @@ build_capture_proxy (tree member, tree init) init = TREE_OPERAND (init, 0); STRIP_NOPS (init); } + STRIP_ANY_LOCATION_WRAPPER (init); gcc_assert (VAR_P (init) || TREE_CODE (init) == PARM_DECL); while (is_normal_capture_proxy (init)) init = DECL_CAPTURED_VARIABLE (init); diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index b4976d8..6d5fdcf 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5026,6 +5026,7 @@ handle_namespace_attrs (tree ns, tree attributes) rather than the namespace as a whole, so we don't touch the NAMESPACE_DECL at all. */ tree x = args ? TREE_VALUE (args) : NULL_TREE; + STRIP_ANY_LOCATION_WRAPPER_SAFE (x); if (x == NULL_TREE || TREE_CODE (x) != STRING_CST || TREE_CHAIN (args)) { warning (OPT_Wattributes, diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8834542..090fb03 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7168,9 +7168,12 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, } } - if (TREE_CODE (postfix_expression) == FUNCTION_DECL - && DECL_BUILT_IN_CLASS (postfix_expression) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (postfix_expression) == BUILT_IN_MEMSET + tree postfix_expr_noloc = postfix_expression; + STRIP_ANY_LOCATION_WRAPPER (postfix_expr_noloc); + + if (TREE_CODE (postfix_expr_noloc) == FUNCTION_DECL + && DECL_BUILT_IN_CLASS (postfix_expr_noloc) == BUILT_IN_NORMAL + && DECL_FUNCTION_CODE (postfix_expr_noloc) == BUILT_IN_MEMSET && vec_safe_length (args) == 3) { tree arg0 = (*args)[0]; @@ -7184,10 +7187,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, warn_for_memset (input_location, arg0, arg2, literal_mask); } - if (TREE_CODE (postfix_expression) == COMPONENT_REF) + if (TREE_CODE (postfix_expr_noloc) == COMPONENT_REF) { - tree instance = TREE_OPERAND (postfix_expression, 0); - tree fn = TREE_OPERAND (postfix_expression, 1); + tree instance = TREE_OPERAND (postfix_expr_noloc, 0); + tree fn = TREE_OPERAND (postfix_expr_noloc, 1); if (processing_template_decl && (type_dependent_object_expression_p (instance) @@ -7221,9 +7224,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, /*koenig_p=*/false, complain); } - else if (TREE_CODE (postfix_expression) == OFFSET_REF - || TREE_CODE (postfix_expression) == MEMBER_REF - || TREE_CODE (postfix_expression) == DOTSTAR_EXPR) + else if (TREE_CODE (postfix_expr_noloc) == OFFSET_REF + || TREE_CODE (postfix_expr_noloc) == MEMBER_REF + || TREE_CODE (postfix_expr_noloc) == DOTSTAR_EXPR) postfix_expression = (build_offset_ref_call_from_tree (postfix_expression, &args, complain)); @@ -8335,18 +8338,22 @@ cp_parser_unary_expression (cp_parser *parser, cp_id_kind * pidk, case NEGATE_EXPR: /* Immediately fold negation of a constant, unless the constant is 0 (since -0 == 0) or it would overflow. */ - if (unary_operator == NEGATE_EXPR && op_ttype == CPP_NUMBER - && CONSTANT_CLASS_P (cast_expression) - && !integer_zerop (cast_expression) - && !TREE_OVERFLOW (cast_expression)) + if (unary_operator == NEGATE_EXPR && op_ttype == CPP_NUMBER) { - tree folded = fold_build1 (unary_operator, - TREE_TYPE (cast_expression), - cast_expression); - if (CONSTANT_CLASS_P (folded) && !TREE_OVERFLOW (folded)) + cast_expression.strip_any_location_wrapper (); + if (CONSTANT_CLASS_P (cast_expression) + && !integer_zerop (cast_expression) + && !TREE_OVERFLOW (cast_expression)) { - expression = cp_expr (folded, loc); - break; + tree folded = fold_build1 (unary_operator, + TREE_TYPE (cast_expression), + cast_expression); + if (CONSTANT_CLASS_P (folded) && !TREE_OVERFLOW (folded)) + { + expression = cp_expr (folded, loc); + expression.maybe_add_location_wrapper (); + break; + } } } /* Fall through. */ @@ -16415,6 +16422,7 @@ cp_parser_template_argument (cp_parser* parser) /*cast_p=*/false, /*template_arg_p=*/true, &idk); + STRIP_ANY_LOCATION_WRAPPER (argument); if (TREE_CODE (argument) != TEMPLATE_PARM_INDEX || !cp_parser_next_token_ends_template_argument_p (parser)) cp_parser_simulate_error (parser); @@ -16444,6 +16452,7 @@ cp_parser_template_argument (cp_parser* parser) /*cast_p=*/false, /*template_arg_p=*/true, &idk); + STRIP_ANY_LOCATION_WRAPPER (argument); if (cp_parser_error_occurred (parser) || !cp_parser_next_token_ends_template_argument_p (parser)) cp_parser_abort_tentative_parse (parser); @@ -34686,6 +34695,7 @@ cp_parser_omp_for_incr (cp_parser *parser, tree decl) ? PREINCREMENT_EXPR : PREDECREMENT_EXPR); cp_lexer_consume_token (parser->lexer); lhs = cp_parser_simple_cast_expression (parser); + STRIP_ANY_LOCATION_WRAPPER (lhs); if (lhs != decl && (!processing_template_decl || !cp_tree_equal (lhs, decl))) return error_mark_node; @@ -34693,6 +34703,7 @@ cp_parser_omp_for_incr (cp_parser *parser, tree decl) } lhs = cp_parser_primary_expression (parser, false, false, false, &idk); + STRIP_ANY_LOCATION_WRAPPER (lhs); if (lhs != decl && (!processing_template_decl || !cp_tree_equal (lhs, decl))) return error_mark_node; @@ -34720,6 +34731,8 @@ cp_parser_omp_for_incr (cp_parser *parser, tree decl) lhs = cp_parser_binary_expression (parser, false, false, PREC_ADDITIVE_EXPRESSION, NULL); token = cp_lexer_peek_token (parser->lexer); + + STRIP_ANY_LOCATION_WRAPPER (lhs); decl_first = (lhs == decl || (processing_template_decl && cp_tree_equal (lhs, decl))); if (decl_first) @@ -34754,6 +34767,7 @@ cp_parser_omp_for_incr (cp_parser *parser, tree decl) if (!decl_first) { + STRIP_ANY_LOCATION_WRAPPER (rhs); if ((rhs != decl && (!processing_template_decl || !cp_tree_equal (rhs, decl))) || op == MINUS_EXPR) @@ -34943,6 +34957,7 @@ cp_parser_omp_for_loop_init (cp_parser *parser, cp_parser_parse_tentatively (parser); decl = cp_parser_primary_expression (parser, false, false, false, &idk); + STRIP_ANY_LOCATION_WRAPPER_SAFE (decl); cp_token *last_tok = cp_lexer_peek_token (parser->lexer); if (!cp_parser_error_occurred (parser) && decl @@ -37563,10 +37578,13 @@ cp_parser_omp_declare_reduction_exprs (tree fndecl, cp_parser *parser) unsigned int i; tree arg; FOR_EACH_VEC_SAFE_ELT (args, i, arg) - if (arg == omp_priv - || (TREE_CODE (arg) == ADDR_EXPR - && TREE_OPERAND (arg, 0) == omp_priv)) - break; + { + STRIP_ANY_LOCATION_WRAPPER (arg); + if (arg == omp_priv + || (TREE_CODE (arg) == ADDR_EXPR + && TREE_OPERAND (arg, 0) == omp_priv)) + break; + } cp_parser_abort_tentative_parse (parser); if (arg == NULL_TREE) error ("one of the initializer call arguments should be %" @@ -39165,6 +39183,7 @@ cp_parser_cilk_simd_linear (cp_parser *parser, tree clauses) e = cp_parser_assignment_expression (parser); e = maybe_constant_value (e); + STRIP_ANY_LOCATION_WRAPPER (e); if (e == error_mark_node) { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 562b927..71fce74 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6063,6 +6063,7 @@ convert_nontype_argument_function (tree type, tree expr, -- the address of an object or function with external [C++11: or internal] linkage. */ + STRIP_ANY_LOCATION_WRAPPER (fn_no_ptr); if (TREE_CODE (fn_no_ptr) != FUNCTION_DECL) { if (complain & tf_error) @@ -6410,6 +6411,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) { tree expr_type; location_t loc = EXPR_LOC_OR_LOC (expr, input_location); + STRIP_ANY_LOCATION_WRAPPER (expr); tree orig_expr = expr; /* Detect immediately string literals as invalid non-type argument. @@ -6475,6 +6477,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) to a null value, but otherwise still need to be of a specific form. */ if (cxx_dialect >= cxx11) { + STRIP_ANY_LOCATION_WRAPPER (expr); if (TREE_CODE (expr) == PTRMEM_CST) /* A PTRMEM_CST is already constant, and a valid template argument for a parameter of pointer to member type, we just want @@ -6506,6 +6509,8 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) else expr = mark_rvalue_use (expr); + STRIP_ANY_LOCATION_WRAPPER (expr); + /* HACK: Due to double coercion, we can get a NOP_EXPR(ADDR_EXPR (arg)) here, which is the tree that we built on the first call (see @@ -6559,6 +6564,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) /* Notice that there are constant expressions like '4 % 0' which do not fold into integer constants. */ + STRIP_ANY_LOCATION_WRAPPER (expr); if (TREE_CODE (expr) != INTEGER_CST && !value_dependent_expression_p (expr)) { @@ -6592,6 +6598,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) conversion (_conv.array_) are applied. */ else if (TYPE_PTROBV_P (type)) { + STRIP_ANY_LOCATION_WRAPPER (expr); tree decayed = expr; /* Look through any NOP_EXPRs around an ADDR_EXPR, whether they come from @@ -6630,6 +6637,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) /* Null pointer values are OK in C++11. */; else if (TREE_CODE (expr) != ADDR_EXPR) { + STRIP_ANY_LOCATION_WRAPPER (expr); if (VAR_P (expr)) { if (complain & tf_error) @@ -6653,7 +6661,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) else { tree decl = TREE_OPERAND (expr, 0); - + STRIP_ANY_LOCATION_WRAPPER (decl); if (!VAR_P (decl)) { if (complain & tf_error) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f292d17..2f37dc8 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1489,6 +1489,8 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, otherwise we'll get an error. Gross, but ... */ STRIP_NOPS (operand); + STRIP_ANY_LOCATION_WRAPPER (operand); + operand = mark_lvalue_use (operand); if (!lvalue_or_else (operand, lv_asm, tf_warning_or_error)) @@ -2249,6 +2251,8 @@ perform_koenig_lookup (cp_expr fn, vec *args, bool template_id = false; location_t loc = fn.get_location (); + fn.strip_any_location_wrapper (); + if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) { /* Use a separate flag to handle null args. */ @@ -4603,7 +4607,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, type = TREE_TYPE (ret); low_bound = TREE_PURPOSE (t); + STRIP_ANY_LOCATION_WRAPPER_SAFE (low_bound); length = TREE_VALUE (t); + STRIP_ANY_LOCATION_WRAPPER_SAFE (length); if ((low_bound && type_dependent_expression_p (low_bound)) || (length && type_dependent_expression_p (length))) return NULL_TREE; @@ -4894,11 +4900,13 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) tree length = TREE_VALUE (t); i--; + STRIP_ANY_LOCATION_WRAPPER_SAFE (low_bound); if (low_bound && TREE_CODE (low_bound) == INTEGER_CST && TYPE_PRECISION (TREE_TYPE (low_bound)) > TYPE_PRECISION (sizetype)) low_bound = fold_convert (sizetype, low_bound); + STRIP_ANY_LOCATION_WRAPPER_SAFE (length); if (length && TREE_CODE (length) == INTEGER_CST && TYPE_PRECISION (TREE_TYPE (length)) @@ -5204,6 +5212,7 @@ omp_reduction_lookup (location_t loc, tree id, tree type, tree *baselinkp, type), false, false); tree fns = id; + STRIP_ANY_LOCATION_WRAPPER (fns); id = NULL_TREE; if (fns && is_overloaded_fn (fns)) { @@ -8062,22 +8071,25 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv, if (decl == NULL) { if (init != NULL) - switch (TREE_CODE (init)) - { - case MODIFY_EXPR: - decl = TREE_OPERAND (init, 0); - init = TREE_OPERAND (init, 1); - break; - case MODOP_EXPR: - if (TREE_CODE (TREE_OPERAND (init, 1)) == NOP_EXPR) - { - decl = TREE_OPERAND (init, 0); - init = TREE_OPERAND (init, 2); - } - break; - default: - break; - } + { + STRIP_ANY_LOCATION_WRAPPER (init); + switch (TREE_CODE (init)) + { + case MODIFY_EXPR: + decl = TREE_OPERAND (init, 0); + init = TREE_OPERAND (init, 1); + break; + case MODOP_EXPR: + if (TREE_CODE (TREE_OPERAND (init, 1)) == NOP_EXPR) + { + decl = TREE_OPERAND (init, 0); + init = TREE_OPERAND (init, 2); + } + break; + default: + break; + } + } if (decl == NULL) { diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index fd4641c..3bb8b8f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -333,6 +333,8 @@ bitfield_p (const_tree ref) tree cp_stabilize_reference (tree ref) { + STRIP_ANY_LOCATION_WRAPPER (ref); + switch (TREE_CODE (ref)) { case NON_DEPENDENT_EXPR: @@ -377,6 +379,8 @@ cp_stabilize_reference (tree ref) bool builtin_valid_in_constant_expr_p (const_tree decl) { + STRIP_ANY_LOCATION_WRAPPER (decl); + if (!(TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)) /* Not a built-in. */ @@ -2425,6 +2429,8 @@ lookup_keep (tree lookup, bool keep) int is_overloaded_fn (tree x) { + STRIP_ANY_LOCATION_WRAPPER (x); + /* A baselink is also considered an overloaded function. */ if (TREE_CODE (x) == OFFSET_REF || TREE_CODE (x) == COMPONENT_REF) @@ -2472,6 +2478,7 @@ really_overloaded_fn (tree x) tree get_fns (tree from) { + STRIP_ANY_LOCATION_WRAPPER (from); /* A baselink is also considered an overloaded function. */ if (TREE_CODE (from) == OFFSET_REF || TREE_CODE (from) == COMPONENT_REF) @@ -4467,6 +4474,7 @@ check_abi_tag_args (tree args, tree name) for (tree arg = args; arg; arg = TREE_CHAIN (arg)) { tree elt = TREE_VALUE (arg); + STRIP_ANY_LOCATION_WRAPPER (elt); if (TREE_CODE (elt) != STRING_CST || (!same_type_ignoring_top_level_qualifiers_p (strip_array_types (TREE_TYPE (elt)), diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a5e4745..027bafb 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1614,6 +1614,8 @@ cxx_sizeof_nowarn (tree type) static tree cxx_sizeof_expr (tree e, tsubst_flags_t complain) { + STRIP_ANY_LOCATION_WRAPPER (e); + if (e == error_mark_node) return error_mark_node; @@ -4202,6 +4204,9 @@ cp_build_binary_op (location_t location, /* True if both operands have arithmetic type. */ bool arithmetic_types_p; + STRIP_ANY_LOCATION_WRAPPER (orig_op0); + STRIP_ANY_LOCATION_WRAPPER (orig_op1); + /* Apply default conversions. */ op0 = orig_op0; op1 = orig_op1; @@ -4394,6 +4399,7 @@ cp_build_binary_op (location_t location, tree type0 = TREE_OPERAND (op0, 0); tree type1 = TREE_OPERAND (op1, 0); tree first_arg = type0; + STRIP_ANY_LOCATION_WRAPPER (first_arg); if (!TYPE_P (type0)) type0 = TREE_TYPE (type0); if (!TYPE_P (type1)) @@ -7751,6 +7757,9 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, { lhs = mark_lvalue_use_nonread (lhs); + STRIP_ANY_LOCATION_WRAPPER (lhs); + STRIP_ANY_LOCATION_WRAPPER (rhs); + tree result = NULL_TREE; tree newrhs = rhs; tree lhstype = TREE_TYPE (lhs); @@ -8888,10 +8897,16 @@ maybe_warn_about_returning_address_of_local (tree retval) for (;;) { if (TREE_CODE (whats_returned) == COMPOUND_EXPR) - whats_returned = TREE_OPERAND (whats_returned, 1); + { + whats_returned = TREE_OPERAND (whats_returned, 1); + STRIP_ANY_LOCATION_WRAPPER (whats_returned); + } else if (CONVERT_EXPR_P (whats_returned) || TREE_CODE (whats_returned) == NON_LVALUE_EXPR) - whats_returned = TREE_OPERAND (whats_returned, 0); + { + whats_returned = TREE_OPERAND (whats_returned, 0); + STRIP_ANY_LOCATION_WRAPPER (whats_returned); + } else break; } @@ -8899,10 +8914,14 @@ maybe_warn_about_returning_address_of_local (tree retval) if (TREE_CODE (whats_returned) != ADDR_EXPR) return false; whats_returned = TREE_OPERAND (whats_returned, 0); + STRIP_ANY_LOCATION_WRAPPER (whats_returned); while (TREE_CODE (whats_returned) == COMPONENT_REF || TREE_CODE (whats_returned) == ARRAY_REF) - whats_returned = TREE_OPERAND (whats_returned, 0); + { + whats_returned = TREE_OPERAND (whats_returned, 0); + STRIP_ANY_LOCATION_WRAPPER (whats_returned); + } if (TREE_CODE (valtype) == REFERENCE_TYPE) { diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index e135b0d..77f6f3e 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -464,6 +464,8 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value, if (TREE_CODE (type) == ERROR_MARK) return; + STRIP_ANY_LOCATION_WRAPPER_SAFE (value); + if (value != 0 && (VAR_P (value) || TREE_CODE (value) == PARM_DECL || TREE_CODE (value) == FIELD_DECL)) @@ -1023,6 +1025,8 @@ digest_init_r (tree type, tree init, bool nested, int flags, location_t loc = EXPR_LOC_OR_LOC (init, input_location); + STRIP_ANY_LOCATION_WRAPPER (init); + /* Initialization of an array of chars from a string constant. The initializer can be optionally enclosed in braces, but reshape_init has already removed them if they were present. */ From patchwork Sat Nov 18 02:52:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467256-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VUqgQmM1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzzd6RjQz9ryr for ; Sat, 18 Nov 2017 13:52:29 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=CE+FO18cH2ARulPWyFCJEhS955O8IrSuhtT3u8MAaODwlHCJvlNMf C+TGygVpicxJitJ0+lzNJCKwfp3v26zAymOSD54kFLjFBqJIq/QkGrTgo4aDqzw1 FN8yYCR6MD0zGCyjuMfMZhxAsWqZLAiEUBjfTV/vLrgIPpN/UGmQw0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=dTGEUwV2t4PAc36zph0FUHn9hkE=; b=VUqgQmM1XTLNCgH4fYG+ jMmUykl3LmkzaTinA7bObW46WXRxKsQn6kuDOtwBMnDaoRKxePu8gZSABaaEclTx rmzf3gKutuOwrb4rpGvnXTX1/oWQPVDu/2i1SMAbPMHEnq304b4hKBxGOdNR4JhM t4iNwu8gs4+XQmYy05491Sc= Received: (qmail 70105 invoked by alias); 18 Nov 2017 02:51:02 -0000 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 Received: (qmail 70075 invoked by uid 89); 18 Nov 2017 02:51:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:50:59 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBD2AC0587CD; Sat, 18 Nov 2017 02:50:58 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30ACF6A025; Sat, 18 Nov 2017 02:50:56 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 09/11] objc: handle location wrappers in objc_maybe_build_component_ref Date: Fri, 17 Nov 2017 21:52:41 -0500 Message-Id: <1510973563-10046-10-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes Fixes "self." e.g. in obj-c++.dg/property/dotsyntax-5.mm. gcc/objc/ChangeLog: * objc-act.c (objc_maybe_build_component_ref): Handle location wrappers. --- gcc/objc/objc-act.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 765192c..15b2dfd 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1376,6 +1376,8 @@ objc_maybe_build_component_ref (tree object, tree property_ident) || TREE_CODE (property_ident) != IDENTIFIER_NODE) return NULL_TREE; + STRIP_ANY_LOCATION_WRAPPER (object); + /* The following analysis of 'object' is similar to the one used for the 'receiver' of a method invocation. We need to determine what 'object' is and find the appropriate property (either declared, From patchwork Sat Nov 18 02:52:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467257-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="svrRQi9U"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydzzv0HkLz9ryr for ; Sat, 18 Nov 2017 13:52:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=dG97VHZzH5ZROegvS68DSGcrSc3Gng5Gln8uCcaeU7xNgnjrG+h/d 0aomxJZSLXmZ2zUkeZJhi1WECvTCjbTFDJIE7dKKoZYyFYVXSkhcStWEgT0vIH8t /NDsOrb5dZBDK5zuGuC/qGdd+imRWT+G1Zs29Lu08om/vLP7lGO0uM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=qbv77lkewgoBIbJktqpVHVAh9C4=; b=svrRQi9Uc7DdmmTzh6wH POpGf9qW0O8ucHL3h2d9I/e7zs7PdkEObuRWHZ8RDCDMcdQjCphu9BG3C2up1SpE ckA6HNrprvHg04cdz9jYSFjsKbCNwFCu4JXdcGuhjrGhk42OW2GxOV7hEwUvNfTS LbI+2AOMM0B0jyvG1tG9698= Received: (qmail 70202 invoked by alias); 18 Nov 2017 02:51:03 -0000 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 Received: (qmail 70125 invoked by uid 89); 18 Nov 2017 02:51:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:51:01 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB27A155; Sat, 18 Nov 2017 02:51:00 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30EF560DCE; Sat, 18 Nov 2017 02:50:58 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 10/11] i386: handle location wrappers in ix86_handle_cconv_attribute Date: Fri, 17 Nov 2017 21:52:42 -0500 Message-Id: <1510973563-10046-11-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes Fixes e.g. g++.dg/abi/regparm1.C gcc/ChangeLog: * config/i386/i386.c (ix86_handle_cconv_attribute): Handle location wrappers. --- gcc/config/i386/i386.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b2c2934..7014e84 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6283,6 +6283,7 @@ ix86_handle_cconv_attribute (tree *node, tree name, } cst = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (cst); if (TREE_CODE (cst) != INTEGER_CST) { warning (OPT_Wattributes, From patchwork Sat Nov 18 02:52:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 839213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467258-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Gy2e0Oje"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yf0086DCWz9ryr for ; Sat, 18 Nov 2017 13:52:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=BMkIWWRanksZ9lMXnEvIcnulpiivZx26rkK44e4hCLbZGszvmaYeC q+nbelqeeLlJ8PWcXkK/5uRA2TX3LMrZMBKY+FKF9naUYikUrCzgdrHfmU0nnI0z GyZGm/ujY1Ms93iNPDq+35cfqIV6T7OwCL14MiyHvuWXoBEcl6fcuc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=rMiKUFdJoQxiCww46tLGxZWHZL0=; b=Gy2e0OjesqDcdRJndJKE WnGOy6LHlMKxuy/EhAeGmaO8ZQnyVseD76wccejt0DlklT+kpbRYTxSp1jU8j3fO FYrSGr2dgYRqgh9K/LStXDc31ZGS/bR5A8+qSYZpRRzZb+sID4OwZwCiWhv3LMNE 9luts/jTxnjEBhbjfSobbXE= Received: (qmail 70543 invoked by alias); 18 Nov 2017 02:51:05 -0000 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 Received: (qmail 70486 invoked by uid 89); 18 Nov 2017 02:51:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4409 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 02:51:03 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD8B2C03BD6E; Sat, 18 Nov 2017 02:51:02 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30D176A025; Sat, 18 Nov 2017 02:51:00 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [PATCH 11/11] config: handle location wrappers in various attributes (untested) Date: Fri, 17 Nov 2017 21:52:43 -0500 Message-Id: <1510973563-10046-12-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> References: <1510350329-48956-1-git-send-email-dmalcolm@redhat.com> <1510973563-10046-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes This is incomplete, and untested, but covers some of the cases where an attribute's value's TREE_CODE is tested (e.g. via STRING_CST). Alternatively, maybe we need a helper function for extracting the value (and location_t) of an attribute, issuing an error if it's not a STRING_CST? gcc/ChangeLog: * config/arc/arc.c (arc_handle_interrupt_attribute): Handle location wrapper. * config/epiphany/epiphany.c (epiphany_handle_interrupt_attribute): Likewise. (epiphany_handle_forwarder_attribute): Likewise. * config/ia64/ia64.c (ia64_handle_model_attribute): Likewise. * config/m32r/m32r.c (m32r_handle_model_attribute): Likewise. * config/mips/mips.c (mips_handle_interrupt_attr): Likewise. (mips_handle_use_shadow_register_set_attr): Likewise. * config/msp430/msp430.c (msp430_attr): Likewise. * config/s390/s390.c (s390_handle_hotpatch_attribute): Likewise. --- gcc/config/arc/arc.c | 2 ++ gcc/config/epiphany/epiphany.c | 3 +++ gcc/config/ia64/ia64.c | 1 + gcc/config/m32r/m32r.c | 2 ++ gcc/config/mips/mips.c | 2 ++ gcc/config/msp430/msp430.c | 2 +- gcc/config/s390/s390.c | 2 ++ 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 7be9f7c..d84c2ab 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -1922,6 +1922,8 @@ arc_handle_interrupt_attribute (tree *, tree name, tree args, int, tree value = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (value); + if (TREE_CODE (value) != STRING_CST) { warning (OPT_Wattributes, diff --git a/gcc/config/epiphany/epiphany.c b/gcc/config/epiphany/epiphany.c index 26b0f3c..ac64d1f 100644 --- a/gcc/config/epiphany/epiphany.c +++ b/gcc/config/epiphany/epiphany.c @@ -496,6 +496,7 @@ epiphany_handle_interrupt_attribute (tree *node, tree name, tree args, } value = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (value); if (TREE_CODE (value) != STRING_CST) { @@ -537,6 +538,8 @@ epiphany_handle_forwarder_attribute (tree *node ATTRIBUTE_UNUSED, value = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (value); + if (TREE_CODE (value) != STRING_CST) { warning (OPT_Wattributes, diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 84a5b56..ae7f1f1 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -742,6 +742,7 @@ ia64_handle_model_attribute (tree *node, tree name, tree args, init_idents (); arg = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (arg); if (arg == small_ident1 || arg == small_ident2) { addr_area = ADDR_AREA_SMALL; diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index f104457..f12a8e9 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -399,6 +399,8 @@ m32r_handle_model_attribute (tree *node ATTRIBUTE_UNUSED, tree name, init_idents (); arg = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (arg); + if (arg != small_ident1 && arg != small_ident2 && arg != medium_ident1 diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 7dde705..2b9f68a 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -1474,6 +1474,7 @@ mips_handle_interrupt_attr (tree *node ATTRIBUTE_UNUSED, tree name, tree args, tree cst; cst = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (cst); if (TREE_CODE (cst) != STRING_CST) { warning (OPT_Wattributes, @@ -1528,6 +1529,7 @@ mips_handle_use_shadow_register_set_attr (tree *node ATTRIBUTE_UNUSED, tree cst; cst = TREE_VALUE (args); + STRIP_ANY_LOCATION_WRAPPER (cst); if (TREE_CODE (cst) != STRING_CST) { warning (OPT_Wattributes, diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 0ee0b6c..ea40628 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1867,7 +1867,7 @@ msp430_attr (tree * node, gcc_assert (TREE_NAME_EQ (name, ATTR_INTR)); tree value = TREE_VALUE (args); - + STRIP_ANY_LOCATION_WRAPPER (value); switch (TREE_CODE (value)) { case STRING_CST: diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 4e08955..2d511b3 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -1110,6 +1110,8 @@ s390_handle_hotpatch_attribute (tree *node, tree name, tree args, { expr = TREE_VALUE (args); expr2 = TREE_VALUE (TREE_CHAIN (args)); + STRIP_ANY_LOCATION_WRAPPER (expr); + STRIP_ANY_LOCATION_WRAPPER (expr2); } if (args == NULL || TREE_CHAIN (args) == NULL) err = 1;