diff mbox series

[10/14] warn_for_memset: handle location wrappers

Message ID 1510350329-48956-11-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series Preserving locations for variable-uses and constants (PR 43486) | expand

Commit Message

David Malcolm Nov. 10, 2017, 9:45 p.m. UTC
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(+)

Comments

Jason Merrill Dec. 11, 2017, 11:41 p.m. UTC | #1
On 11/10/2017 04:45 PM, David Malcolm wrote:
> 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.

Despite my earlier comment about fold_for_warn, I guess this is 
specifically interested in literals, so this is OK.

Jason
diff mbox series

Patch

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)