public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Adjust ubsan/vla-1.c test
@ 2013-12-02 15:58 Marek Polacek
  2013-12-02 16:02 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2013-12-02 15:58 UTC (permalink / raw)
  To: GCC Patches, Jakub Jelinek; +Cc: Konstantin Serebryany

This patch puts every VLA test into its separate function to make it
less like fail due to stack overflow.

Ran ubsan testsuite, ok for trunk?

2013-12-02  Marek Polacek  <polacek@redhat.com>

testsuite/
	* c-c++-common/ubsan/vla-1.c: Split the tests into individual
	functions.

--- gcc/testsuite/c-c++-common/ubsan/vla-1.c.mp4	2013-12-02 16:32:21.139139722 +0100
+++ gcc/testsuite/c-c++-common/ubsan/vla-1.c	2013-12-02 16:48:28.791731232 +0100
@@ -1,33 +1,104 @@
 /* { dg-do run } */
 /* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable" } */
 
-static int
+typedef long int V;
+int x = -1;
+double di = -3.2;
+V v = -6;
+
+static int __attribute__ ((noinline, noclone))
 bar (void)
 {
-  return -42;
+  return -4;
 }
 
-typedef long int V;
-int
-main (void)
+static void __attribute__ ((noinline, noclone))
+fn1 (void)
 {
-  int x = -1;
-  double di = -3.2;
-  V v = -666;
-
   int a[x];
-  int aa[x][x];
-  int aaa[x][x][x];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn2 (void)
+{
+  int a[x][x];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn3 (void)
+{
+  int a[x][x][x];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn4 (void)
+{
   int b[x - 4];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn5 (void)
+{
   int c[(int) di];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn6 (void)
+{
   int d[1 + x];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn7 (void)
+{
   int e[1 ? x : -1];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn8 (void)
+{
   int f[++x];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn9 (void)
+{
   int g[(signed char) --x];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn10 (void)
+{
   int h[(++x, --x, x)];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn11 (void)
+{
   int i[v];
+}
+
+static void __attribute__ ((noinline, noclone))
+fn12 (void)
+{
   int j[bar ()];
+}
 
+int
+main (void)
+{
+  fn1 ();
+  fn2 ();
+  fn3 ();
+  fn4 ();
+  fn5 ();
+  fn6 ();
+  fn7 ();
+  fn8 ();
+  fn9 ();
+  fn10 ();
+  fn11 ();
+  fn12 ();
   return 0;
 }
 
@@ -44,5 +115,5 @@ main (void)
 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value 0(\n|\r\n|\r)" } */
 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -666(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -42(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -6(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -4(\n|\r\n|\r)" } */

	Marek

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Adjust ubsan/vla-1.c test
  2013-12-02 15:58 [PATCH] Adjust ubsan/vla-1.c test Marek Polacek
@ 2013-12-02 16:02 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2013-12-02 16:02 UTC (permalink / raw)
  To: Marek Polacek; +Cc: GCC Patches, Konstantin Serebryany

On Mon, Dec 02, 2013 at 04:57:49PM +0100, Marek Polacek wrote:
> This patch puts every VLA test into its separate function to make it
> less like fail due to stack overflow.
> 
> Ran ubsan testsuite, ok for trunk?

Ok, thanks.
> 2013-12-02  Marek Polacek  <polacek@redhat.com>
> 
> testsuite/
> 	* c-c++-common/ubsan/vla-1.c: Split the tests into individual
> 	functions.

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-02 16:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-02 15:58 [PATCH] Adjust ubsan/vla-1.c test Marek Polacek
2013-12-02 16:02 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).