fail35-,pass53-,pass54-frag.c: New tests.
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 28 Oct 2004 21:21:59 +0000 (21:21 +0000)
committerFrank Ch. Eigler <fche@gcc.gnu.org>
Thu, 28 Oct 2004 21:21:59 +0000 (21:21 +0000)
2004-10-28  Frank Ch. Eigler  <fche@redhat.com>

* testsuite/libmudflap.c/fail35-,pass53-,pass54-frag.c: New tests.
* testsuite/libmudflap.c/pass35-frag.c: Correct embedded warning
message.

From-SVN: r89783

libmudflap/ChangeLog
libmudflap/testsuite/libmudflap.c/fail35-frag.c [new file with mode: 0644]
libmudflap/testsuite/libmudflap.c/pass35-frag.c
libmudflap/testsuite/libmudflap.c/pass53-frag.c [new file with mode: 0644]
libmudflap/testsuite/libmudflap.c/pass54-frag.c [new file with mode: 0644]

index ffb681e..b437bc4 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-28  Frank Ch. Eigler  <fche@redhat.com>
+
+       * testsuite/libmudflap.c/fail35-,pass53-,pass54-frag.c: New tests.
+       * testsuite/libmudflap.c/pass35-frag.c: Correct embedded warning
+       message.
+
 2004-10-25  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR other/18138
diff --git a/libmudflap/testsuite/libmudflap.c/fail35-frag.c b/libmudflap/testsuite/libmudflap.c/fail35-frag.c
new file mode 100644 (file)
index 0000000..101fe29
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+
+struct k
+{
+  int p;
+  struct {
+    int m;
+  } q;
+};
+
+int
+main ()
+{
+  volatile struct k *l = malloc (sizeof (int)); /* make it only big enough for k.p */
+  /* Confirm that we instrument this nested construct
+     COMPONENT_REF(COMPONENT_REF(INDIRECT_REF)). */
+  l->q.m = 5;
+  return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*" } */
+/* { dg-do run { xfail *-*-* } } */
index 95dafab..14d2c94 100644 (file)
@@ -3,7 +3,7 @@
 #include <string.h>
 
 extern char end [];   /* Any old symbol we're sure will be defined. */
-/* { dg-warning "cannot track unknown size extern 'end'" "cannot track unknown size extern" { target *-*-* } 0 } */
+/* { dg-warning "cannot track unknown size extern" "cannot track unknown size extern" { target *-*-* } 0 } */
 
 int main ()
 {
diff --git a/libmudflap/testsuite/libmudflap.c/pass53-frag.c b/libmudflap/testsuite/libmudflap.c/pass53-frag.c
new file mode 100644 (file)
index 0000000..6afb293
--- /dev/null
@@ -0,0 +1,41 @@
+int foo1 ()
+{
+  union { int l; char c[sizeof (int)]; } k1;
+  char *m;
+  k1.l = 0;
+  /* This test variant triggers ADDR_EXPR of k explicitly in order to
+     ensure it's registered with the runtime.  */
+  m = k1.c;
+  k1.c [sizeof (int)-1] = m[sizeof (int)-2];
+}
+
+int foo2 ()
+{
+  union { int l; char c[sizeof (int)]; } k2;
+  k2.l = 0;
+  /* Since this access is known-in-range, k need not be registered
+     with the runtime, but then this access better not be instrumented
+     either.  */
+  k2.c [sizeof (int)-1] ++;
+  return k2.l;
+}
+
+int foo3idx = sizeof (int)-1;
+
+int foo3 ()
+{
+  union { int l; char c[sizeof (int)]; } k3;
+  k3.l = 0;
+  /* NB this test uses foo3idx, an extern variable, to defeat mudflap
+     known-in-range-index optimizations.  */
+  k3.c [foo3idx] ++;
+  return k3.l;
+}
+
+int main ()
+{
+  foo1 ();
+  foo2 ();
+  foo3 ();
+  return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass54-frag.c b/libmudflap/testsuite/libmudflap.c/pass54-frag.c
new file mode 100644 (file)
index 0000000..59cf2fa
--- /dev/null
@@ -0,0 +1,33 @@
+struct k 
+{
+  struct {
+    int b;
+    int c;
+  } a;
+};
+
+static struct k l;
+static struct k m;
+
+void foo ()
+{
+  /* This should not be instrumented. */ 
+  l.a.b = 5;
+}
+
+void bar ()
+{
+  /* This should not be instrumented. */ 
+  m.a.b = 5;
+}
+
+int main ()
+{
+  /* Force TREE_ADDRESSABLE on "l" only.  */
+  volatile int *k = & l.a.c;
+  *k = 8;
+  __mf_set_options ("-mode-violate");
+  foo ();
+  bar ();
+  __mf_set_options ("-mode-check");
+}