On Fri, Jun 05, 2020 at 01:41:16PM -0600, Martin Sebor via Gcc-patches wrote:
> PR c++/86568 - -Wnonnull warnings should highlight the relevant argument not 
> the closing parenthesis
> 
> gcc/c-family/ChangeLog:
> 
>       PR c++/86568
>       * c-common.c (struct nonnull_arg_ctx): Add members.
>       (check_function_nonnull): Use nonnull_arg_ctx as argument.  Handle
>       C++ member functions specially.  Consider the this pointer implicitly
>       nonnull.
>       (check_nonnull_arg): Use location of argument when available.
>       (check_function_arguments): Use nonnull_arg_ctx as argument.
> 
> gcc/ChangeLog:
> 
>       PR c++/86568
>       * calls.c (maybe_warn_rdwr_sizes): Use location of argument if
>       available.
>       * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same.  Adjust
>       indentation.
>       * tree.c (get_nonnull_args): Consider the this pointer implicitly
>       nonnull.
>       * gcc/var-tracking.c (deps_vec): New type.
>       (var_loc_dep_vec): New function.
>       (VAR_LOC_DEP_VEC): Use it.

This broke c-c++-common/builtin-arith-overflow-1.c on all arches.

Fixed thusly, tested on x86_64-linux, committed to trunk as obvious.

2020-06-29  Jakub Jelinek  <ja...@redhat.com>

        PR c++/86568
        * c-c++-common/builtin/arith-overflow-1.c (generic_3, typed_3_null):
        Adjust dg-warning.

--- gcc/testsuite/c-c++-common/builtin-arith-overflow-1.c.jj    2020-01-12 
11:54:37.001404537 +0100
+++ gcc/testsuite/c-c++-common/builtin-arith-overflow-1.c       2020-06-29 
13:41:27.057188795 +0200
@@ -82,20 +82,20 @@ generic_3 (int a, int b, int c)
     x += __builtin_add_overflow (0, 0, (enum E *)0);
   */
 
-  x += __builtin_sub_overflow (0, 0, (char *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_add_overflow (0, 0, (short *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_add_overflow (a, b, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_sub_overflow (a, b, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_mul_overflow (a, b, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_add_overflow (a, 1, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_sub_overflow (a, 2, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_mul_overflow (a, 3, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_add_overflow (4, b, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_sub_overflow (5, b, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_mul_overflow (6, b, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_add_overflow (7, 8, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_sub_overflow (9, 10, (int *)0);   /* { dg-warning "null 
argument" } */
-  x += __builtin_mul_overflow (11, 12, (int *)0);   /* { dg-warning "null 
argument" } */
+  x += __builtin_sub_overflow (0, 0, (char *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_add_overflow (0, 0, (short *)0);   /* { dg-warning "argument 
3 null" } */
+  x += __builtin_add_overflow (a, b, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_sub_overflow (a, b, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_mul_overflow (a, b, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_add_overflow (a, 1, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_sub_overflow (a, 2, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_mul_overflow (a, 3, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_add_overflow (4, b, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_sub_overflow (5, b, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_mul_overflow (6, b, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_add_overflow (7, 8, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_sub_overflow (9, 10, (int *)0);   /* { dg-warning "argument 3 
null" } */
+  x += __builtin_mul_overflow (11, 12, (int *)0);   /* { dg-warning "argument 
3 null" } */
 
   return x;
 }
@@ -167,34 +167,34 @@ typed_3_null (int a, int b)
 {
   int x = 0;
 
-  x += __builtin_sadd_overflow (a, b, (int *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_uadd_overflow (a, b, (unsigned *)0); /* { dg-warning "null 
argument" } */
+  x += __builtin_sadd_overflow (a, b, (int *)0); /* { dg-warning "argument 3 
null" } */
+  x += __builtin_uadd_overflow (a, b, (unsigned *)0); /* { dg-warning 
"argument 3 null" } */
 
-  x += __builtin_saddl_overflow (a, b, (long *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_uaddl_overflow (a, b, (unsigned long *)0); /* { dg-warning 
"null argument" } */
+  x += __builtin_saddl_overflow (a, b, (long *)0); /* { dg-warning "argument 3 
null" } */
+  x += __builtin_uaddl_overflow (a, b, (unsigned long *)0); /* { dg-warning 
"argument 3 null" } */
 
-  x += __builtin_saddll_overflow (a, b, (long long *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_uaddll_overflow (a, b, (unsigned long long *)0); /* { 
dg-warning "null argument" } */
+  x += __builtin_saddll_overflow (a, b, (long long *)0); /* { dg-warning 
"argument 3 null" } */
+  x += __builtin_uaddll_overflow (a, b, (unsigned long long *)0); /* { 
dg-warning "argument 3 null" } */
 
 
-  x += __builtin_ssub_overflow (a, b, (int *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_usub_overflow (a, b, (unsigned *)0); /* { dg-warning "null 
argument" } */
+  x += __builtin_ssub_overflow (a, b, (int *)0); /* { dg-warning "argument 3 
null" } */
+  x += __builtin_usub_overflow (a, b, (unsigned *)0); /* { dg-warning 
"argument 3 null" } */
 
-  x += __builtin_ssubl_overflow (a, b, (long *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_usubl_overflow (a, b, (unsigned long *)0); /* { dg-warning 
"null argument" } */
+  x += __builtin_ssubl_overflow (a, b, (long *)0); /* { dg-warning "argument 3 
null" } */
+  x += __builtin_usubl_overflow (a, b, (unsigned long *)0); /* { dg-warning 
"argument 3 null" } */
 
-  x += __builtin_ssubll_overflow (a, b, (long long *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_usubll_overflow (a, b, (unsigned long long *)0); /* { 
dg-warning "null argument" } */
+  x += __builtin_ssubll_overflow (a, b, (long long *)0); /* { dg-warning 
"argument 3 null" } */
+  x += __builtin_usubll_overflow (a, b, (unsigned long long *)0); /* { 
dg-warning "argument 3 null" } */
 
 
-  x += __builtin_smul_overflow (a, b, (int *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_umul_overflow (a, b, (unsigned *)0); /* { dg-warning "null 
argument" } */
+  x += __builtin_smul_overflow (a, b, (int *)0); /* { dg-warning "argument 3 
null" } */
+  x += __builtin_umul_overflow (a, b, (unsigned *)0); /* { dg-warning 
"argument 3 null" } */
 
-  x += __builtin_smull_overflow (a, b, (long *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_umull_overflow (a, b, (unsigned long *)0); /* { dg-warning 
"null argument" } */
+  x += __builtin_smull_overflow (a, b, (long *)0); /* { dg-warning "argument 3 
null" } */
+  x += __builtin_umull_overflow (a, b, (unsigned long *)0); /* { dg-warning 
"argument 3 null" } */
 
-  x += __builtin_smulll_overflow (a, b, (long long *)0); /* { dg-warning "null 
argument" } */
-  x += __builtin_umulll_overflow (a, b, (unsigned long long *)0); /* { 
dg-warning "null argument" } */
+  x += __builtin_smulll_overflow (a, b, (long long *)0); /* { dg-warning 
"argument 3 null" } */
+  x += __builtin_umulll_overflow (a, b, (unsigned long long *)0); /* { 
dg-warning "argument 3 null" } */
 
   return x;
 }


        Jakub

Reply via email to