public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] New testcase
@ 2008-05-22 16:55 Richard Guenther
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Guenther @ 2008-05-22 16:55 UTC (permalink / raw)
  To: gcc-patches


While trying to work on PR36291.

Committed as obvious.

Richard.

2008-05-22  Richard Guenther  <rguenther@suse.de>

	* gcc.c-torture/execute/20080522-1.c: New testcase.

Index: testsuite/gcc.c-torture/execute/20080522-1.c
===================================================================
--- testsuite/gcc.c-torture/execute/20080522-1.c	(revision 0)
+++ testsuite/gcc.c-torture/execute/20080522-1.c	(revision 0)
@@ -0,0 +1,43 @@
+/* This testcase is to make sure we have i in referenced vars and that we
+   properly compute aliasing for the loads and stores.  */
+
+extern void abort (void);
+
+static int i;
+static int *p = &i;
+
+int __attribute__((noinline))
+foo(int *q)
+{
+  *p = 1;
+  *q = 2;
+  return *p;
+}
+
+int __attribute__((noinline))
+bar(int *q)
+{
+  *q = 2;
+  *p = 1;
+  return *q;
+}
+
+int main()
+{
+  int j = 0;
+
+  if (foo(&i) != 2)
+    abort ();
+  if (bar(&i) != 1)
+    abort ();
+  if (foo(&j) != 1)
+    abort ();
+  if (j != 2)
+    abort ();
+  if (bar(&j) != 2)
+    abort ();
+  if (j != 2)
+    abort ();
+
+  return 0;
+}

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH] New testcase
@ 2009-10-20 16:00 Richard Guenther
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Guenther @ 2009-10-20 16:00 UTC (permalink / raw)
  To: gcc-patches


Committed.

2009-10-20  Richard Guenther  <rguenther@suse.de>

	* gcc.dg/lto/20091020-3_0.c: New testcase.

Index: testsuite/gcc.dg/lto/20091020-3_0.c
===================================================================
--- testsuite/gcc.dg/lto/20091020-3_0.c	(revision 0)
+++ testsuite/gcc.dg/lto/20091020-3_0.c	(revision 0)
@@ -0,0 +1,20 @@
+/* { dg-lto-do assemble } */
+
+typedef __SIZE_TYPE__ size_t;
+static int stack_dir;
+static void find_stack_direction ()
+{
+  static char *addr = ((void *)0);
+  auto char dummy;
+  if (addr == ((void *)0))
+    {
+      addr = &(dummy);
+      find_stack_direction ();
+    }
+}
+void * C_alloca (size_t size)
+{
+  if (stack_dir == 0)
+    find_stack_direction ();
+}
+

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH] New testcase
@ 2012-06-15 11:43 Richard Guenther
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Guenther @ 2012-06-15 11:43 UTC (permalink / raw)
  To: gcc-patches


This adds a testcase I reduced from a genmodes miscompile with one of
my pending VRP patches.

Committed.

Richard.

2012-06-15  Richard Guenther  <rguenther@suse.de>

	* gcc.c-torture/execute/20120615-1.c: New testcase.

Index: gcc/testsuite/gcc.c-torture/execute/20120615-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/20120615-1.c	(revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/20120615-1.c	(revision 0)
@@ -0,0 +1,16 @@
+extern void abort (void);
+
+void __attribute__((noinline,noclone))
+     test1(int i)
+{
+  if (i == 12)
+    return;
+  if (i != 17)
+    {
+      if (i == 15)
+	return;
+      abort ();
+    }
+}
+
+int main() { test1 (15); return 0; }

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH] New testcase
@ 2023-03-14  7:29 Richard Biener
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Biener @ 2023-03-14  7:29 UTC (permalink / raw)
  To: gcc-patches

This is a reduced testcase for an issue I ran into when trying to
improve PTA compile-time further, there wasn't any C family runfail
in the testsuite for this.

Pushed.

	* g++.dg/torture/20230313.C: New testcase.
---
 gcc/testsuite/g++.dg/torture/20230313.C | 109 ++++++++++++++++++++++++
 1 file changed, 109 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/torture/20230313.C

diff --git a/gcc/testsuite/g++.dg/torture/20230313.C b/gcc/testsuite/g++.dg/torture/20230313.C
new file mode 100644
index 00000000000..d1f348003bd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/20230313.C
@@ -0,0 +1,109 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fno-exceptions -fno-rtti" } */
+
+extern "C" void free (void *);
+void fancy_abort () { __builtin_abort (); }
+struct vec_prefix
+{
+  unsigned m_alloc : 1;
+  unsigned m_using_auto_storage : 1;
+  unsigned m_num;
+};
+struct vl_ptr
+;
+struct va_heap
+{
+  typedef vl_ptr default_layout;
+};
+template<typename ,
+         typename A ,
+         typename = typename A::default_layout>
+struct vec
+;
+template<typename T, typename A>
+struct vec<T, A, int>
+{
+  T & operator[] (unsigned ix)
+    {
+      int *__trans_tmp_2;
+      !m_vecpfx.m_num ? fancy_abort (), 0 : 0;
+      __trans_tmp_2 =  reinterpret_cast <T *> (this + 1);
+      return __trans_tmp_2[ix];
+    }
+  bool iterate (unsigned , T *ptr) {
+      *ptr = 0;
+      return false;
+  }
+  void embedded_init (unsigned , unsigned num, unsigned aut)
+    {
+      m_vecpfx.m_alloc =
+	  m_vecpfx.m_using_auto_storage = aut;
+      m_vecpfx.m_num = num;
+    }
+  void quick_grow (unsigned len)
+    {
+      !m_vecpfx.m_alloc ? fancy_abort (), 0 : m_vecpfx.m_num = len;
+    }
+  vec_prefix m_vecpfx;
+};
+template<typename T, int N >
+struct auto_vec : vec<T, va_heap>
+{
+  auto_vec ()
+  {
+    m_auto.embedded_init (N, 0, 1);
+    long off = (char *) &m_auto - (char *) this;
+    this->m_vec = (vec<T, va_heap, int> *) ((char *) this + off);
+  }
+  ~auto_vec ()
+  {
+    this->release ();
+  }
+  vec<T, va_heap, int> m_auto;
+  char m_data;
+};
+template<typename T>
+struct vec<T, va_heap>
+{
+void
+release ()
+{
+  bool __trans_tmp_1 =  m_vec ? m_vec->m_vecpfx.m_using_auto_storage : false;
+  if (__trans_tmp_1)
+      return;
+  vec<int, va_heap, int> *&v = m_vec;
+    free (m_vec);
+    v = nullptr;
+}
+T &operator[] (unsigned ix) { return (*m_vec)[ix]; }
+bool
+iterate (unsigned ix, T *ptr) {
+    m_vec->iterate (ix, ptr);
+    return false;
+}
+void
+quick_grow (unsigned len)
+{
+  m_vec->quick_grow (len);
+}
+  vec<T, va_heap, int> *m_vec;
+};
+void test_auto_alias ()
+{
+  volatile int i = 1;
+  auto_vec<int, 8> v;
+  v.quick_grow (2);
+  v[0] = 1;
+  v[1] = 2;
+  int val;
+  for (int ix = i; v.iterate (ix, &val); ix++)
+    if (val != 2)
+      __builtin_abort ();
+  if (val != 0)
+    __builtin_abort ();
+}
+int main()
+{
+  test_auto_alias ();
+  return 0;
+}
-- 
2.35.3

^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <20230314072924.C1A34385840C@sourceware.org>]

end of thread, other threads:[~2023-03-20 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-22 16:55 [PATCH] New testcase Richard Guenther
2009-10-20 16:00 Richard Guenther
2012-06-15 11:43 Richard Guenther
2023-03-14  7:29 Richard Biener
     [not found] <20230314072924.C1A34385840C@sourceware.org>
2023-03-20 10:15 ` Jakub Jelinek
2023-03-20 10:59   ` Richard Biener

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).