This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix up testcase (PR tree-optimization/78482)


Hi!

The testcase uses char and can't work properly with unsigned char (otherwise
c >= 0 is always true).

In addition to that I've noticed that the testcase as is actually doesn't
fail with the unfixed gcc, it will just print 2 on stdout.

The following has been tested on x86_64-linux and i686-linux with both
the broken compiler (FAILs) and fixed one (PASSes).

Ok for trunk?

2016-11-23  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/78482
	* gcc.dg/torture/pr78482.c (c, d): Use signed char instead of char.
	(bar): New function.
	(main): Call bar instead of printf.

--- gcc/testsuite/gcc.dg/torture/pr78482.c.jj	2016-11-23 16:47:32.000000000 +0100
+++ gcc/testsuite/gcc.dg/torture/pr78482.c	2016-11-23 19:59:31.000000000 +0100
@@ -1,9 +1,9 @@
+/* PR tree-optimization/78482 */
 /* { dg-do run } */
 
-int printf(const char*, ...);
 short a = 65531;
 int b = 3, f;
-char c, d;
+signed char c, d;
 static void fn1(int p1)
 {
   short e;
@@ -22,13 +22,22 @@ static void fn1(int p1)
     }
 }
 
+__attribute__((noinline, noclone))
+int bar (const char *x, int y)
+{
+  asm volatile ("" : "+g" (x), "+g" (y) : : "memory");
+  if (y == 2)
+    __builtin_abort ();
+  return 0;
+}
+
 int main()
 {
   for (; c >= 0; c--)
     {
       if (!b)
 	{
-	  printf("%d\n", 2);
+	  bar("%d\n", 2);
 	  continue;
 	}
       fn1(a);

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]