gcc/c-family/ChangeLog:
        * c-format.c (check_format_arg): Strip any location wrapper around
        format_tree.
---
 gcc/c-family/c-format.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
index 164d035..6b436ec 100644
--- a/gcc/c-family/c-format.c
+++ b/gcc/c-family/c-format.c
@@ -1536,6 +1536,8 @@ check_format_arg (void *ctx, tree format_tree,
 
   location_t fmt_param_loc = EXPR_LOC_OR_LOC (format_tree, input_location);
 
+  STRIP_ANY_LOCATION_WRAPPER (format_tree);
+
   if (VAR_P (format_tree))
     {
       /* Pull out a constant value if the front end didn't.  */
@@ -1598,6 +1600,7 @@ check_format_arg (void *ctx, tree format_tree,
     }
   res->format_string_loc = EXPR_LOC_OR_LOC (format_tree, input_location);
   format_tree = TREE_OPERAND (format_tree, 0);
+  STRIP_ANY_LOCATION_WRAPPER (format_tree);
   if (format_types[info->format_type].flags 
       & (int) FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL)
     {
@@ -1634,7 +1637,10 @@ check_format_arg (void *ctx, tree format_tree,
   if (TREE_CODE (format_tree) == ARRAY_REF
       && tree_fits_shwi_p (TREE_OPERAND (format_tree, 1))
       && (offset += tree_to_shwi (TREE_OPERAND (format_tree, 1))) >= 0)
-    format_tree = TREE_OPERAND (format_tree, 0);
+    {
+      format_tree = TREE_OPERAND (format_tree, 0);
+      STRIP_ANY_LOCATION_WRAPPER (format_tree);
+    }
   if (offset < 0)
     {
       res->number_non_literal++;
@@ -1650,6 +1656,7 @@ check_format_arg (void *ctx, tree format_tree,
         const char a[3] = "foo";).  */
       array_size = DECL_SIZE_UNIT (format_tree);
       format_tree = array_init;
+      STRIP_ANY_LOCATION_WRAPPER (format_tree);
     }
   if (TREE_CODE (format_tree) != STRING_CST)
     {
-- 
1.8.5.3

Reply via email to