OSDN Git Service

PR target/53272
authorhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 May 2012 15:27:58 +0000 (15:27 +0000)
committerhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 May 2012 15:27:58 +0000 (15:27 +0000)
* gcc.dg/torture/pr53272-1.c, gcc.dg/torture/pr53272-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187286 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr53272-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr53272-2.c [new file with mode: 0644]

index 1e922f2..c27ed90 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-08  Hans-Peter Nilsson  <hp@axis.com>
+
+       PR target/53272
+       * gcc.dg/torture/pr53272-1.c, gcc.dg/torture/pr53272-2.c: New test.
+
 2012-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/53239
diff --git a/gcc/testsuite/gcc.dg/torture/pr53272-1.c b/gcc/testsuite/gcc.dg/torture/pr53272-1.c
new file mode 100644 (file)
index 0000000..a8fc91c
--- /dev/null
@@ -0,0 +1,39 @@
+/* { dg-do run } */
+/* { dg-additional-sources "pr53272-2.c" } */
+struct rtc_class_ops {
+ int (*f)(void *, unsigned int enabled);
+};
+
+struct rtc_device
+{
+ void *owner;
+ const struct rtc_class_ops *ops;
+ int ops_lock;
+};
+
+__attribute__ ((__noinline__, __noclone__))
+extern int foo(void *);
+__attribute__ ((__noinline__, __noclone__))
+extern void foobar(void *);
+
+__attribute__ ((__noinline__, __noclone__))
+int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
+{
+ int err;
+ asm volatile ("");
+
+ err = foo(&rtc->ops_lock);
+
+ if (err)
+  return err;
+
+ if (!rtc->ops)
+  err = -19;
+ else if (!rtc->ops->f)
+  err = -22;
+ else
+  err = rtc->ops->f(rtc->owner, enabled);
+
+ foobar(&rtc->ops_lock);
+ return err;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr53272-2.c b/gcc/testsuite/gcc.dg/torture/pr53272-2.c
new file mode 100644 (file)
index 0000000..f5065a7
--- /dev/null
@@ -0,0 +1,39 @@
+__attribute__ ((__noinline__, __noclone__))
+int foo(void *x)
+{
+  asm ("");
+  return *(int *) x != 42;
+}
+
+__attribute__ ((__noinline__, __noclone__))
+void foobar(void *x)
+{
+  asm ("");
+  if (foo(x))
+    __builtin_abort();
+}
+
+struct rtc_class_ops {
+ int (*f)(void *, unsigned int enabled);
+};
+
+struct rtc_device
+{
+ void *owner;
+ struct rtc_class_ops *ops;
+ int ops_lock;
+};
+
+extern __attribute__ ((__noinline__, __noclone__))
+int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int);
+
+int main(void)
+{
+ struct rtc_class_ops ops = {(void *) 0};
+  struct rtc_device dev1 = {0, &ops, 42};
+
+  if (rtc_update_irq_enable (&dev1, 1) != -22)
+    __builtin_abort ();
+
+  __builtin_exit (0);
+}