This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 10/14] warn_for_memset: handle location wrappers
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Nathan Sidwell <nathan at acm dot org>, Jakub Jelinek <jakub at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>, David Malcolm <dmalcolm at redhat dot com>
- Date: Fri, 10 Nov 2017 16:45:25 -0500
- Subject: [PATCH 10/14] warn_for_memset: handle location wrappers
- Authentication-results: sourceware.org; auth=none
- References: <CADzB+2kfB26fTGXk2AVWuN1mv641OrcEBze+Lq-KexXHeS=Y9A@mail.gmail.com> <1510350329-48956-1-git-send-email-dmalcolm@redhat.com>
gcc/c-family/ChangeLog:
* c-warn.c (warn_for_memset): Strip any location wrappers
from arg0 and arg2.
gcc/cp/ChangeLog:
* parser.c (cp_parser_postfix_expression): Before warn_for_memset,
strip any wrapper around "arg2" before testing for CONST_DECL.
---
gcc/c-family/c-warn.c | 3 +++
gcc/cp/parser.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 245c37d..67e6db6 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -1850,6 +1850,9 @@ void
warn_for_memset (location_t loc, tree arg0, tree arg2,
int literal_zero_mask)
{
+ STRIP_ANY_LOCATION_WRAPPER (arg0);
+ STRIP_ANY_LOCATION_WRAPPER (arg2);
+
if (warn_memset_transposed_args
&& integer_zerop (arg2)
&& (literal_zero_mask & (1 << 2)) != 0
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 54029ef..aee211f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -7176,6 +7176,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
tree arg0 = (*args)[0];
tree arg1 = (*args)[1];
tree arg2 = (*args)[2];
+ STRIP_ANY_LOCATION_WRAPPER (arg2);
int literal_mask = ((!!integer_zerop (arg1) << 1)
| (!!integer_zerop (arg2) << 2));
if (TREE_CODE (arg2) == CONST_DECL)
--
1.8.5.3