[testsuite] Tweak Wrestrict.c

Message ID 2187656.LVUmuXea5R@polaris
State New
Headers show
Series
  • [testsuite] Tweak Wrestrict.c
Related show

Commit Message

Eric Botcazou Jan. 16, 2018, 10:54 p.m.
This test fails on strict-alignment platforms because a call to memcpy is not 
turned into a simple move and thus yields an additional warning:

warning: '__builtin_memcpy' writing 4 bytes into a region of size 0 overflows 
the destination [-Wstringop-overflow=]

The attached patch tweaks the test so that this call to memcpy is preserved on 
the other platforms too (by adding one character to the string) and adds the 
additional dg-warning directive.

Tested on visium-elf & x86_64-suse-linux, applied on the mainline as obvious.


2018-01-16  Eric Botcazou  <ebotcazou@adacore.com>

	* c-c++-common/Wrestrict.c (test_strcpy_range): Bump string size of one
	test and add dg-warning for the -Wstringop-overflow warning.

-- 
Eric Botcazou

Comments

Martin Sebor Jan. 16, 2018, 11:41 p.m. | #1
On 01/16/2018 03:54 PM, Eric Botcazou wrote:
> This test fails on strict-alignment platforms because a call to memcpy is not

> turned into a simple move and thus yields an additional warning:

>

> warning: '__builtin_memcpy' writing 4 bytes into a region of size 0 overflows

> the destination [-Wstringop-overflow=]


There should be just one warning per call, and (as it is) -Wrestrict
should suppress -Wstringop-overflow.  This suppression was a recent
change (r256683).  Is it not working for you?  The new assertion
fails for me with your change:

FAIL: c-c++-common/Wrestrict.c  -Wc++-compat  memcpy (test for warnings, 
line 761)

Martin


>

> The attached patch tweaks the test so that this call to memcpy is preserved on

> the other platforms too (by adding one character to the string) and adds the

> additional dg-warning directive.

>

> Tested on visium-elf & x86_64-suse-linux, applied on the mainline as obvious.

>

>

> 2018-01-16  Eric Botcazou  <ebotcazou@adacore.com>

>

> 	* c-c++-common/Wrestrict.c (test_strcpy_range): Bump string size of one

> 	test and add dg-warning for the -Wstringop-overflow warning.

>
Eric Botcazou Jan. 17, 2018, 9:08 a.m. | #2
> There should be just one warning per call, and (as it is) -Wrestrict

> should suppress -Wstringop-overflow.  This suppression was a recent

> change (r256683). 


Sorry, the changes indeed crossed, I'm going to revert mine.

-- 
Eric Botcazou

Patch

Index: c-c++-common/Wrestrict.c
===================================================================
--- c-c++-common/Wrestrict.c	(revision 256562)
+++ c-c++-common/Wrestrict.c	(working copy)
@@ -758,7 +758,8 @@  void test_strcpy_range (void)
   T (8, "012", a + r, a);            /* { dg-warning "accessing 4 bytes at offsets \\\[3, \[0-9\]+] and 0 may overlap 1 byte at offset 3" "strcpy" } */
 
   r = SR (DIFF_MAX - 2, DIFF_MAX - 1);
-  T (8, "012", a + r, a);            /* { dg-warning "accessing 4 bytes at offsets \\\[\[0-9\]+, \[0-9\]+] and 0 overlaps" "strcpy" } */
+  T (8, "0123", a + r, a);            /* { dg-warning "accessing 5 bytes at offsets \\\[\[0-9\]+, \[0-9\]+] and 0 overlaps" "strcpy" } */
+                                      /* { dg-warning "writing 5 bytes into a region of size 0 overflows" "memcpy" { target *-*-* } .-1 } */
 
   /* Exercise the full range of ptrdiff_t.  */
   r = signed_value ();