Re: [PATCH/testsuite] avoid test failures with -fpic

2018-02-27 Thread Jeff Law
On 02/26/2018 04:47 PM, Martin Sebor wrote:
> Compiling a number of tests with -fpic results in failures
> because the tests make use of non-inline, extern helper
> functions defined within, and these helpers must be assumed
> to have been superimposed elsewhere.
> 
> For example:
> https://gcc.gnu.org/ml/gcc-testresults/2018-02/msg01762.html
> 
> I took a quick pass through the failures and declared
> the helpers static to avoid them.  I only did this in failure
> tests I recognized because I introduced them myself being unaware
> that building the tests with -fpic was expected to work.
> 
> This should make the -fpic test results a lot cleaner than
> they currently are, although I don't think it brings them
> up to par with non-fpic results.
> 
> Unless there are objections in the next day or so I'll commit
> the fixes as obvious.
OK.


jeff



[PATCH/testsuite] avoid test failures with -fpic

2018-02-26 Thread Martin Sebor

Compiling a number of tests with -fpic results in failures
because the tests make use of non-inline, extern helper
functions defined within, and these helpers must be assumed
to have been superimposed elsewhere.

For example:
https://gcc.gnu.org/ml/gcc-testresults/2018-02/msg01762.html

I took a quick pass through the failures and declared
the helpers static to avoid them.  I only did this in failure
tests I recognized because I introduced them myself being unaware
that building the tests with -fpic was expected to work.

This should make the -fpic test results a lot cleaner than
they currently are, although I don't think it brings them
up to par with non-fpic results.

Unless there are objections in the next day or so I'll commit
the fixes as obvious.

Martin

gcc/testsuite/ChangeLog:

	* c-c++-common/Warray-bounds-2.c: Declare helper static to avoid
	-fpic test failures.
	* c-c++-common/Wrestrict-2.c: Same.
	* c-c++-common/Wstringop-truncation.c: Same.
	* gcc.dg/Warray-bounds-22.c: Same.
	* gcc.dg/Wstringop-overflow.c: Same.
	* gcc.dg/attr-alloc_size-3.c (unsigned_range): Same.
	(signed_range): Same.
	(unsigned_anti_range): Same.
	* gcc.dg/attr-alloc_size-4.c (unsigned_range): Same.
	(signed_range): Same.
	(unsigned_anti_range): Same.
	* gcc.dg/attr-alloc_size-7.c: Same.
	* gcc.dg/attr-alloc_size-8.c: Same.
	* gcc.dg/builtin-alloc-size.c: Same.
	* gcc.dg/builtin-stpncpy.c: Same.
	* gcc.dg/builtins-nonnull.c: Same.
	* gcc.dg/nonnull-4.c (g16_1_3_5_7_11_13): Same.
	* gcc.dg/pr79214.c: Same.
	* gcc.dg/tree-ssa/builtin-snprintf-warn-1.c: Same.
	* gcc.dg/tree-ssa/builtin-snprintf-warn-2.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-5.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-11.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-12.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-13.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-14.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-15.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-19.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-9.c: Same.


diff --git a/gcc/testsuite/c-c++-common/Warray-bounds-2.c b/gcc/testsuite/c-c++-common/Warray-bounds-2.c
index becb3d4..db05f04 100644
--- a/gcc/testsuite/c-c++-common/Warray-bounds-2.c
+++ b/gcc/testsuite/c-c++-common/Warray-bounds-2.c
@@ -24,7 +24,8 @@ struct __attribute__ ((packed)) Array
 
 /* Exercise memcpy out-of-bounds offsets with an array of known size.  */
 
-void wrap_memcpy_src_xsize (char *d, const char *s, ptrdiff_t i, size_t n)
+static void
+wrap_memcpy_src_xsize (char *d, const char *s, ptrdiff_t i, size_t n)
 {
   memcpy (d, s + i, n);   /* { dg-warning "offset 46 is out of the bounds \\\[0, 45] of object .ar. with type .(struct )?Array." "memcpy" } */
 }
@@ -39,7 +40,8 @@ void call_memcpy_src_xsize (char *d, size_t n)
 
 /* Exercise memcpy out-of-bounds offsets with an array of unknown size.  */
 
-void wrap_memcpy_src_diff_max (char *d, const char *s, ptrdiff_t i, size_t n)
+static void
+wrap_memcpy_src_diff_max (char *d, const char *s, ptrdiff_t i, size_t n)
 {
   memcpy (d, s + i, n);   /* { dg-warning "pointer overflow between offset \[0-9\]+ and size 3" "memcpy" } */
 }
@@ -49,7 +51,8 @@ void call_memcpy_src_diff_max (char *d, const char *s, size_t n)
   wrap_memcpy_src_diff_max (d, s, MAX, 3);
 }
 
-void wrap_memcpy_dst_xsize (char *d, const char *s, ptrdiff_t i, size_t n)
+static void
+wrap_memcpy_dst_xsize (char *d, const char *s, ptrdiff_t i, size_t n)
 {
   memcpy (d + i, s, n);   /* { dg-warning "offset 47 is out of the bounds \\\[0, 45] of object .ar1. with type .(struct )?Array." "memcpy" } */
 }
@@ -62,7 +65,8 @@ void call_memcpy_dst_xsize (const char *s, size_t n)
   sink ();
 }
 
-void wrap_memcpy_dst_diff_max (char *d, const char *s, ptrdiff_t i, size_t n)
+static void
+wrap_memcpy_dst_diff_max (char *d, const char *s, ptrdiff_t i, size_t n)
 {
   memcpy (d + i, s, n);   /* { dg-warning "offset -?\[0-9\]+ is out of the bounds \\\[0, 45] of object .ar2. with type .(struct )?Array." "memcpy" } */
 }
@@ -76,7 +80,7 @@ void call_memcpy_dst_diff_max (const char *s, size_t n)
 }
 
 
-void wrap_strcat_src_xsize (char *d, const char *s, ptrdiff_t i)
+static void wrap_strcat_src_xsize (char *d, const char *s, ptrdiff_t i)
 {
   strcat (d, s + i);   /* { dg-warning "offset 46 is out of the bounds \\\[0, 45] of object .ar3. with type .(struct )?Array." "strcat" } */
 }
@@ -89,7 +93,7 @@ void call_strcat_src_xsize (char *d)
   sink ();
 }
 
-void wrap_strcat_dst_xsize (char *d, const char *s, ptrdiff_t i)
+static void wrap_strcat_dst_xsize (char *d, const char *s, ptrdiff_t i)
 {
   strcat (d + i, s);   /* { dg-warning "offset 47 is out of the bounds \\\[0, 45] of object .ar4. with type .(struct )?Array." "strcat" } */
 }
@@ -103,7 +107,7 @@ void call_strcat_dst_xsize (const char *s)
 }
 
 
-void wrap_strcpy_src_xsize (char *d, const char *s, ptrdiff_t i)
+static void wrap_strcpy_src_xsize (char *d, const char *s, ptrdiff_t i)
 {
   strcpy