Re: [PATCH] incorrect arguments designated in -Wnonnull for arrays

2021-07-28 Thread Jeff Law via Gcc-patches




On 7/28/2021 12:56 AM, Uecker, Martin wrote:

Am Dienstag, den 27.07.2021, 10:55 -0600 schrieb Martin Sebor:

On 7/26/21 12:22 PM, Jeff Law via Gcc-patches wrote:

On 7/25/2021 10:23 AM, Uecker, Martin wrote:

Two arguments are switched for -Wnonnull when
warning about array parameters with bounds > 0
and which are NULL.

This patch corrects the mistake.

Martin


2021-07-25  Martin Uecker  

gcc/
   * calls.c (maybe_warn_rdwr_sizes): Correct argument
   numbers in warning that were switched.

gcc/testsuite/
   * gcc.dg/Wnonnull-4.c: Correct argument numbers in warnings.

I'll defer to Martin Sebor on this.

Martin S., can you cover the review of this patch from Martin U?

The patch is correct.  Thanks for the fix!  It would ideally go
into GCC 11 as well.

Committed.

Should I also push it to origin/releases/gcc-11 ?

Yes, the branch should be open for bugfixes.
jeff


Re: [PATCH] incorrect arguments designated in -Wnonnull for arrays

2021-07-28 Thread Uecker, Martin
Am Dienstag, den 27.07.2021, 10:55 -0600 schrieb Martin Sebor:
> On 7/26/21 12:22 PM, Jeff Law via Gcc-patches wrote:
> > 
> > On 7/25/2021 10:23 AM, Uecker, Martin wrote:
> > > Two arguments are switched for -Wnonnull when
> > > warning about array parameters with bounds > 0
> > > and which are NULL.
> > > 
> > > This patch corrects the mistake.
> > > 
> > > Martin
> > > 
> > > 
> > > 2021-07-25  Martin Uecker  
> > > 
> > > gcc/
> > >   * calls.c (maybe_warn_rdwr_sizes): Correct argument
> > >   numbers in warning that were switched.
> > > 
> > > gcc/testsuite/
> > >   * gcc.dg/Wnonnull-4.c: Correct argument numbers in warnings.
> > I'll defer to Martin Sebor on this.
> > 
> > Martin S., can you cover the review of this patch from Martin U?
> 
> The patch is correct.  Thanks for the fix!  It would ideally go
> into GCC 11 as well.

Committed.

Should I also push it to origin/releases/gcc-11 ?


Martin



Re: [PATCH] incorrect arguments designated in -Wnonnull for arrays

2021-07-27 Thread Martin Sebor via Gcc-patches

On 7/26/21 12:22 PM, Jeff Law via Gcc-patches wrote:



On 7/25/2021 10:23 AM, Uecker, Martin wrote:

Two arguments are switched for -Wnonnull when
warning about array parameters with bounds > 0
and which are NULL.

This patch corrects the mistake.

Martin


2021-07-25  Martin Uecker  

gcc/
  * calls.c (maybe_warn_rdwr_sizes): Correct argument
  numbers in warning that were switched.

gcc/testsuite/
  * gcc.dg/Wnonnull-4.c: Correct argument numbers in warnings.

I'll defer to Martin Sebor on this.

Martin S., can you cover the review of this patch from Martin U?


The patch is correct.  Thanks for the fix!  It would ideally go
into GCC 11 as well.

Martin


Re: [PATCH] incorrect arguments designated in -Wnonnull for arrays

2021-07-26 Thread Jeff Law via Gcc-patches




On 7/25/2021 10:23 AM, Uecker, Martin wrote:

Two arguments are switched for -Wnonnull when
warning about array parameters with bounds > 0
and which are NULL.

This patch corrects the mistake.

Martin


2021-07-25  Martin Uecker  

gcc/
  * calls.c (maybe_warn_rdwr_sizes): Correct argument
  numbers in warning that were switched.

gcc/testsuite/
  * gcc.dg/Wnonnull-4.c: Correct argument numbers in warnings.

I'll defer to Martin Sebor on this.

Martin S., can you cover the review of this patch from Martin U?

Thanks,
Jeff




[PATCH] incorrect arguments designated in -Wnonnull for arrays

2021-07-25 Thread Uecker, Martin

Two arguments are switched for -Wnonnull when
warning about array parameters with bounds > 0
and which are NULL.

This patch corrects the mistake.

Martin


2021-07-25  Martin Uecker  

gcc/
 * calls.c (maybe_warn_rdwr_sizes): Correct argument
 numbers in warning that were switched.

gcc/testsuite/
 * gcc.dg/Wnonnull-4.c: Correct argument numbers in warnings.



diff --git a/gcc/calls.c b/gcc/calls.c
index d2413a280cf..c54c57206c7 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2128,8 +2128,8 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree 
fntype, tree exp)
  "array %s is null but "
  "the corresponding bound argument "
  "%i value is %s",
- sizidx + 1, argtypestr.c_str (),
- ptridx + 1, sizstr))
+ ptridx + 1, argtypestr.c_str (),
+ sizidx + 1, sizstr))
arg_warned = OPT_Wnonnull;
}
  else if (warning_at (loc, OPT_Wnonnull,
diff --git a/gcc/testsuite/gcc.dg/Wnonnull-4.c 
b/gcc/testsuite/gcc.dg/Wnonnull-4.c
index 180a40d4606..2c1c45a9856 100644
--- a/gcc/testsuite/gcc.dg/Wnonnull-4.c
+++ b/gcc/testsuite/gcc.dg/Wnonnull-4.c
@@ -27,9 +27,9 @@ void test_fca_n (int r_m1)
   T (  0);
 
   // Verify positive bounds.
-  T (  1);  // { dg-warning "argument 1 of variable length array 
'char\\\[n]' is null but
the corresponding bound argument 2 value is 1" }
-  T (  9);  // { dg-warning "argument 1 of variable length array 
'char\\\[n]' is null but
the corresponding bound argument 2 value is 9" }
-  T (max);  // { dg-warning "argument 1 of variable length array 
'char\\\[n]' is null but
the corresponding bound argument 2 value is \\d+" }
+  T (  1);  // { dg-warning "argument 2 of variable length array 
'char\\\[n]' is null but
the corresponding bound argument 1 value is 1" }
+  T (  9);  // { dg-warning "argument 2 of variable length array 
'char\\\[n]' is null but
the corresponding bound argument 1 value is 9" }
+  T (max);  // { dg-warning "argument 2 of variable length array 
'char\\\[n]' is null but
the corresponding bound argument 1 value is \\d+" }
 }
 
 
@@ -55,9 +55,9 @@ void test_fsa_x_n (int r_m1)
   T (  0);
 
   // Verify positive bounds.
-  T (  1);  // { dg-warning "argument 1 of variable length array 
'short int\\\[]\\\[n]' is
null but the corresponding bound argument 2 value is 1" }
-  T (  9);  // { dg-warning "argument 1 of variable length array 
'short int\\\[]\\\[n]' is
null but the corresponding bound argument 2 value is 9" }
-  T (max);  // { dg-warning "argument 1 of variable length array 
'short int\\\[]\\\[n]' is
null but the corresponding bound argument 2 value is \\d+" }
+  T (  1);  // { dg-warning "argument 2 of variable length array 
'short int\\\[]\\\[n]' is
null but the corresponding bound argument 1 value is 1" }
+  T (  9);  // { dg-warning "argument 2 of variable length array 
'short int\\\[]\\\[n]' is
null but the corresponding bound argument 1 value is 9" }
+  T (max);  // { dg-warning "argument 2 of variable length array 
'short int\\\[]\\\[n]' is
null but the corresponding bound argument 1 value is \\d+" }
 }
 
 
@@ -83,9 +83,9 @@ void test_fia_1_n (int r_m1)
   T (  0);
 
   // Verify positive bounds.
-  T (  1);  // { dg-warning "argument 1 of variable length array 
'int\\\[1]\\\[n]' is null
but the corresponding bound argument 2 value is 1" }
-  T (  9);  // { dg-warning "argument 1 of variable length array 
'int\\\[1]\\\[n]' is null
but the corresponding bound argument 2 value is 9" }
-  T (max);  // { dg-warning "argument 1 of variable length array 
'int\\\[1]\\\[n]' is null
but the corresponding bound argument 2 value is \\d+" }
+  T (  1);  // { dg-warning "argument 2 of variable length array 
'int\\\[1]\\\[n]' is null
but the corresponding bound argument 1 value is 1" }
+  T (  9);  // { dg-warning "argument 2 of variable length array 
'int\\\[1]\\\[n]' is null
but the corresponding bound argument 1 value is 9" }
+  T (max);  // { dg-warning "argument 2 of variable length array 
'int\\\[1]\\\[n]' is null
but the corresponding bound argument 1 value is \\d+" }
 }
 
 
@@ -111,9 +111,9 @@ void test_fla_3_n (int r_m1)
   T (  0);
 
   // Verify positive bounds.
-  T (  1);  // { dg-warning "argument 1 of variable length array 'long 
int\\\[3]\\\[n]' is
null but the corresponding bound argument 2 value is 1" }
-  T (  9);  // { dg-warning "argument 1 of variable length array 'long 
int\\\[3]\\\[n]' is
null but the corresponding bound argument 2 value is 9" }
-  T (max);  // { dg-warning "argument 1 of variable length array 'long 
int\\\[3]\\\[n]' is
null but the corresponding bound argument 2 value is \\d+" }
+  T (