summaryrefslogtreecommitdiff
path: root/libmudflap/testsuite/libmudflap.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmudflap/testsuite/libmudflap.c')
-rw-r--r--libmudflap/testsuite/libmudflap.c/cfrags.exp15
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail1-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail10-frag.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail11-frag.c19
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail12-frag.c19
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail13-frag.c26
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail14-frag.c29
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail15-frag.c27
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail16-frag.c26
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail17-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail18-frag.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail19-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail2-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail20-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail21-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail22-frag.c17
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail23-frag.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail25-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail26-frag.c24
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail27-frag.c24
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail28-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail29-frag.c17
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail3-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail30-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail31-frag.c22
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail4-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail5-frag.c14
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail6-frag.c17
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail7-frag.c17
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail8-frag.c19
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail9-frag.c21
-rw-r--r--libmudflap/testsuite/libmudflap.c/hook-allocstuff.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass-stratcliff.c319
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass1-frag.c9
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass10-frag.c12
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass11-frag.c15
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass12-frag.c15
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass13-frag.c17
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass14-frag.c20
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass15-frag.c23
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass16-frag.c22
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass17-frag.c9
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass18-frag.c27
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass19-frag.c11
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass2-frag.c9
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass20-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass21-frag.c15
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass22-frag.c23
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass23-frag.c29
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass24-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass25-frag.c15
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass26-frag.c52
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass29-frag.c15
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass3-frag.c9
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass30-frag.c12
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass32-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass33-frag.c17
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass34-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass35-frag.c14
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass36-frag.c15
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass38-frag.c9
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass4-frag.c9
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass42-frag.c17
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass43-frag.c11
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass44-frag.c14
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass45-frag.c31
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass46-frag.c18
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass5-frag.c11
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass6-frag.c14
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass7-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass8-frag.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass9-frag.c16
72 files changed, 1560 insertions, 0 deletions
diff --git a/libmudflap/testsuite/libmudflap.c/cfrags.exp b/libmudflap/testsuite/libmudflap.c/cfrags.exp
new file mode 100644
index 00000000000..bef2f91c312
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/cfrags.exp
@@ -0,0 +1,15 @@
+
+libmudflap-init [find_gcc]
+
+dg-init
+
+global srcdir
+foreach flags [list {} {-static} {-O2} {-O3}] {
+ foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c/*.c]] {
+ set bsrc [file tail $srcfile]
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+ dg-runtest $srcfile $flags "-fmudflap"
+ }
+}
+
+dg-finish
diff --git a/libmudflap/testsuite/libmudflap.c/fail1-frag.c b/libmudflap/testsuite/libmudflap.c/fail1-frag.c
new file mode 100644
index 00000000000..1e48fff8771
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail1-frag.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+volatile int foo [10];
+foo[10] = 0;
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. foo.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail10-frag.c b/libmudflap/testsuite/libmudflap.c/fail10-frag.c
new file mode 100644
index 00000000000..db135d5c451
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail10-frag.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+volatile int foo[10];
+int sz = sizeof (int);
+
+volatile char *bar = (char *)foo;
+bar [sz * 10] = 0;
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. foo.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail11-frag.c b/libmudflap/testsuite/libmudflap.c/fail11-frag.c
new file mode 100644
index 00000000000..72038fdba30
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail11-frag.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int i = 10;
+char *x = (char *) malloc (i * sizeof (char));
+
+while (i--)
+{
+ ++x;
+ *x = 0;
+}
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail12-frag.c b/libmudflap/testsuite/libmudflap.c/fail12-frag.c
new file mode 100644
index 00000000000..da8bfb7c046
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail12-frag.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int i = 10;
+int *x = (int *) malloc (i * sizeof (int));
+
+while (i--)
+{
+ ++x;
+ *x = 0;
+}
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail13-frag.c b/libmudflap/testsuite/libmudflap.c/fail13-frag.c
new file mode 100644
index 00000000000..9fd3e255712
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail13-frag.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct a {
+ int x;
+ int y;
+ char z;
+};
+
+struct b {
+ int x;
+ int y;
+};
+
+struct b k;
+
+(*((volatile struct a *) &k)).z = 'q';
+
+return 0;
+}
+/* { dg-output "mudflap violation 1..check/write.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. k.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail14-frag.c b/libmudflap/testsuite/libmudflap.c/fail14-frag.c
new file mode 100644
index 00000000000..e66cc94c49b
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail14-frag.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct a {
+ int x;
+ int y;
+ char z;
+};
+
+struct b {
+ int x;
+ int y;
+};
+
+volatile struct b k;
+volatile struct a *p;
+
+p = (struct a*) &k;
+
+p->z = 'q';
+
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. k.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail15-frag.c b/libmudflap/testsuite/libmudflap.c/fail15-frag.c
new file mode 100644
index 00000000000..5d7ae744973
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail15-frag.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct base {
+ int basic;
+};
+
+struct derived {
+ struct base common;
+ char extra;
+};
+
+volatile struct base b;
+volatile struct base *bp;
+
+bp = (struct base *)&b;
+
+bp->basic = 10;
+((struct derived volatile *)bp)->extra = 'x';
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. b.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail16-frag.c b/libmudflap/testsuite/libmudflap.c/fail16-frag.c
new file mode 100644
index 00000000000..317e2744731
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail16-frag.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct base {
+ int basic;
+};
+
+struct derived {
+ struct base common;
+ char extra;
+};
+
+struct base *bp;
+
+bp = (struct base *) malloc (sizeof (struct base));;
+
+bp->basic = 10;
+((struct derived *)bp)->extra = 'x';
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail17-frag.c b/libmudflap/testsuite/libmudflap.c/fail17-frag.c
new file mode 100644
index 00000000000..5af67f13858
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail17-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+
+char * x;
+int foo;
+x = (char *) malloc (10);
+strcpy (x, "123456789");
+foo = strlen (x+10);
+x [foo] = 1; /* we just just use foo to force execution of strlen */
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail18-frag.c b/libmudflap/testsuite/libmudflap.c/fail18-frag.c
new file mode 100644
index 00000000000..dde150a8457
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail18-frag.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+/* One cannot redeclare __mf_lc_mask in proper C from instrumented
+ code, because of the way the instrumentation code emits its decls. */
+extern unsigned foo __asm__ ("__mf_lc_mask");
+unsigned *bar = &foo;
+*bar = 4;
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.__mf_lc_mask.*no-access.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail19-frag.c b/libmudflap/testsuite/libmudflap.c/fail19-frag.c
new file mode 100644
index 00000000000..7e446b40503
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail19-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct foo {
+ int bar [10];
+};
+
+struct foo *k = (struct foo *) malloc (2 * sizeof(int));
+k->bar[5] = 9;
+free (k);
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail2-frag.c b/libmudflap/testsuite/libmudflap.c/fail2-frag.c
new file mode 100644
index 00000000000..7672e60c602
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail2-frag.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+volatile int foo [10][10];
+foo[10][0] = 0;
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. foo.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail20-frag.c b/libmudflap/testsuite/libmudflap.c/fail20-frag.c
new file mode 100644
index 00000000000..0dd8bb7f983
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail20-frag.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+volatile char *p = (char *) 0;
+*p = 5;
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.NULL.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail21-frag.c b/libmudflap/testsuite/libmudflap.c/fail21-frag.c
new file mode 100644
index 00000000000..4ab4a09f3b0
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail21-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+ int *bar = (int *) malloc (sizeof (int));
+/* Make an access here to get &foo into the lookup cache. */
+*bar = 5;
+__mf_watch (bar, sizeof(int));
+/* This access should trigger the watch violation. */
+*bar = 10;
+/* NOTREACHED */
+return 0;
+}
+/* { dg-output "mudflap violation 1.*watch.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail22-frag.c b/libmudflap/testsuite/libmudflap.c/fail22-frag.c
new file mode 100644
index 00000000000..7dd7103d359
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail22-frag.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct boo { int a; };
+int c;
+struct boo *b = malloc (sizeof (struct boo));
+__mf_set_options ("-check-initialization");
+c = b->a;
+(void) malloc (c); /* some dummy use of c */
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.malloc region.*1r/0w.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail23-frag.c b/libmudflap/testsuite/libmudflap.c/fail23-frag.c
new file mode 100644
index 00000000000..bb1b52ec7e0
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail23-frag.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char zoo [10];
+
+int main ()
+{
+int i = strlen ("012345") + strlen ("6789") + strlen ("01"); /* 11 */
+zoo[i] = 'a';
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*zoo.*static.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail25-frag.c b/libmudflap/testsuite/libmudflap.c/fail25-frag.c
new file mode 100644
index 00000000000..acac5236b42
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail25-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+__mf_set_options ("-check-initialization");
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+/* bar[2] = 'z'; */ /* don't touch memcpy source */
+memcpy(foo+1, bar+1, 9);
+return 0;
+}
+/* { dg-output "mudflap violation 1.*check.read.*memcpy source.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*malloc region.*alloc time.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail26-frag.c b/libmudflap/testsuite/libmudflap.c/fail26-frag.c
new file mode 100644
index 00000000000..88484d6adc4
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail26-frag.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+
+__mf_set_options ("-check-initialization");
+foo = (char *)malloc (1);
+
+/* These two operations each expand to a read-modify-write.
+ * Even though the end result is that every bit of foo[0] is
+ * eventually written to deterministically, the first read
+ * triggers an uninit error. Ideally, it shouldn't, so this
+ * should be treated more like a regular XFAIL. */
+foo[0] &= 0xfe;
+foo[0] |= 0x01;
+
+return foo[0];
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*malloc region.*1r/0w.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail27-frag.c b/libmudflap/testsuite/libmudflap.c/fail27-frag.c
new file mode 100644
index 00000000000..7168dfc61b2
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail27-frag.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char volatile *
+__attribute__((noinline))
+foo (unsigned i)
+{
+ char volatile buffer[10];
+ char volatile *k = i ? & buffer[i] : NULL; /* defeat addr-of-local-returned warning */
+ return k;
+}
+
+int main ()
+{
+char volatile *f = foo (5);
+f[0] = 'b';
+
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*buffer.*alloc.*dealloc" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail28-frag.c b/libmudflap/testsuite/libmudflap.c/fail28-frag.c
new file mode 100644
index 00000000000..7d61c57f34b
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail28-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int foo (int *u, int i)
+{
+ return u[i]; /* this dereference should be instrumented */
+}
+
+int main ()
+{
+int *k = malloc (6);
+return foo (k, 8);
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*malloc region.*alloc" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail29-frag.c b/libmudflap/testsuite/libmudflap.c/fail29-frag.c
new file mode 100644
index 00000000000..2024064dc73
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail29-frag.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int foo (int u[10])
+{
+ return u[8]; /* this dereference should be instrumented */
+}
+
+int main ()
+{
+int *k = malloc (6);
+return foo (k);
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*malloc region.*alloc" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail3-frag.c b/libmudflap/testsuite/libmudflap.c/fail3-frag.c
new file mode 100644
index 00000000000..98c1dbae165
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail3-frag.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+volatile int foo [10][10][10];
+foo[9][10][0] = 0;
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. foo.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail30-frag.c b/libmudflap/testsuite/libmudflap.c/fail30-frag.c
new file mode 100644
index 00000000000..8bfea61cbb2
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail30-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int foo (int u)
+{
+ return u*u;
+}
+
+int main ()
+{
+int *k = malloc(5);
+int j = foo (k[8]); /* this call argument should be instrumented */
+return j;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*malloc region.*alloc" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail31-frag.c b/libmudflap/testsuite/libmudflap.c/fail31-frag.c
new file mode 100644
index 00000000000..b15056c970c
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail31-frag.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int h (int i, int j);
+
+int main ()
+{
+ int z = h (4, 10);
+ return 0;
+}
+
+int h (int i, int j)
+{
+ int k[i];
+ k[j] = i;
+ return j;
+}
+
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*\(h\).*k" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail4-frag.c b/libmudflap/testsuite/libmudflap.c/fail4-frag.c
new file mode 100644
index 00000000000..a3423e6c36b
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail4-frag.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char foo [10];
+strcpy(foo, "1234567890");
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. foo.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail5-frag.c b/libmudflap/testsuite/libmudflap.c/fail5-frag.c
new file mode 100644
index 00000000000..a08569fe773
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail5-frag.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char foo [15];
+char bar [10];
+memcpy(foo, bar, 11);
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*.main. bar.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail6-frag.c b/libmudflap/testsuite/libmudflap.c/fail6-frag.c
new file mode 100644
index 00000000000..1904a88711a
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail6-frag.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (15);
+
+memcpy(foo, bar, 11);
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail7-frag.c b/libmudflap/testsuite/libmudflap.c/fail7-frag.c
new file mode 100644
index 00000000000..580d045386d
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail7-frag.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+foo = (char *)malloc (12);
+bar = (char *)malloc (10);
+
+memcpy(foo+1, bar+1, 10);
+return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*malloc region.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail8-frag.c b/libmudflap/testsuite/libmudflap.c/fail8-frag.c
new file mode 100644
index 00000000000..cc2fbdaac4c
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail8-frag.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(bar);
+
+memcpy(foo, bar, 10);
+return 0;
+}
+/* { dg-output "mudflap violation 1.*memcpy source.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*malloc region.*alloc time.*dealloc time.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail9-frag.c b/libmudflap/testsuite/libmudflap.c/fail9-frag.c
new file mode 100644
index 00000000000..029fda5d4d0
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail9-frag.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(foo);
+
+bar[4] = 'a'; /* touch source buffer */
+memcpy(foo, bar, 10);
+return 0;
+}
+
+/* { dg-output "mudflap violation 1.*memcpy dest.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*malloc region.*alloc time.*dealloc time.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c b/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c
new file mode 100644
index 00000000000..dc25375488d
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main ()
+{
+ char *foo = (char *) malloc (10);
+ strcpy (foo, "hello");
+ foo = (char *) realloc (foo, 20);
+ printf ("%s", foo);
+ if (strcmp (foo, "hello"))
+ abort ();
+ free (foo);
+ printf (" world\n");
+ return 0;
+}
+/* { dg-output "hello world" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c b/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c
new file mode 100644
index 00000000000..894f10ffa96
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c
@@ -0,0 +1,319 @@
+/* Test for string function add boundaries of usable memory.
+ Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define _GNU_SOURCE 1
+#define __USE_GNU
+
+/* Make sure we don't test the optimized inline functions if we want to
+ test the real implementation. */
+#undef __USE_STRING_INLINES
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+int
+main (int argc, char *argv[])
+{
+ int size = sysconf (_SC_PAGESIZE);
+ char *adr, *dest;
+ int result = 0;
+
+ adr = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0);
+ dest = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0);
+ if (adr == MAP_FAILED || dest == MAP_FAILED)
+ {
+ if (errno == ENOSYS)
+ puts ("No test, mmap not available.");
+ else
+ {
+ printf ("mmap failed: %m");
+ result = 1;
+ }
+ }
+ else
+ {
+ int inner, middle, outer;
+
+ mprotect(adr, size, PROT_NONE);
+ mprotect(adr + 2 * size, size, PROT_NONE);
+ adr += size;
+
+ mprotect(dest, size, PROT_NONE);
+ mprotect(dest + 2 * size, size, PROT_NONE);
+ dest += size;
+
+ memset (adr, 'T', size);
+
+ /* strlen test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (inner = MAX (outer, size - 64); inner < size; ++inner)
+ {
+ adr[inner] = '\0';
+
+ if (strlen (&adr[outer]) != (size_t) (inner - outer))
+ {
+ printf ("strlen flunked for outer = %d, inner = %d\n",
+ outer, inner);
+ result = 1;
+ }
+
+ adr[inner] = 'T';
+ }
+ }
+
+ /* strchr test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (middle = MAX (outer, size - 64); middle < size; ++middle)
+ {
+ for (inner = middle; inner < size; ++inner)
+ {
+ char *cp;
+ adr[middle] = 'V';
+ adr[inner] = '\0';
+
+ cp = strchr (&adr[outer], 'V');
+
+ if ((inner == middle && cp != NULL)
+ || (inner != middle
+ && (cp - &adr[outer]) != middle - outer))
+ {
+ printf ("strchr flunked for outer = %d, middle = %d, "
+ "inner = %d\n", outer, middle, inner);
+ result = 1;
+ }
+
+ adr[inner] = 'T';
+ adr[middle] = 'T';
+ }
+ }
+ }
+
+ /* Special test. */
+ adr[size - 1] = '\0';
+ if (strchr (&adr[size - 1], '\n') != NULL)
+ {
+ puts ("strchr flunked for test of empty string at end of page");
+ result = 1;
+ }
+
+ /* strrchr test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (middle = MAX (outer, size - 64); middle < size; ++middle)
+ {
+ for (inner = middle; inner < size; ++inner)
+ {
+ char *cp;
+ adr[middle] = 'V';
+ adr[inner] = '\0';
+
+ cp = strrchr (&adr[outer], 'V');
+
+ if ((inner == middle && cp != NULL)
+ || (inner != middle
+ && (cp - &adr[outer]) != middle - outer))
+ {
+ printf ("strrchr flunked for outer = %d, middle = %d, "
+ "inner = %d\n", outer, middle, inner);
+ result = 1;
+ }
+
+ adr[inner] = 'T';
+ adr[middle] = 'T';
+ }
+ }
+ }
+
+#ifndef __FreeBSD__
+ /* rawmemchr test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (middle = MAX (outer, size - 64); middle < size; ++middle)
+ {
+ char *cp;
+ adr[middle] = 'V';
+
+ cp = (char *) rawmemchr (&adr[outer], 'V');
+
+ if (cp - &adr[outer] != middle - outer)
+ {
+ printf ("rawmemchr flunked for outer = %d, middle = %d\n",
+ outer, middle);
+ result = 1;
+ }
+
+ adr[middle] = 'T';
+ }
+ }
+#endif
+
+ /* strcpy test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (inner = MAX (outer, size - 64); inner < size; ++inner)
+ {
+ adr[inner] = '\0';
+
+ if (strcpy (dest, &adr[outer]) != dest
+ || strlen (dest) != (size_t) (inner - outer))
+ {
+ printf ("strcpy flunked for outer = %d, inner = %d\n",
+ outer, inner);
+ result = 1;
+ }
+
+ adr[inner] = 'T';
+ }
+ }
+
+ /* strncpy tests */
+ adr[size-1] = 'T';
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ size_t len;
+
+ for (len = 0; len < size - outer; ++len)
+ {
+ if (strncpy (dest, &adr[outer], len) != dest
+ || memcmp (dest, &adr[outer], len) != 0)
+ {
+ printf ("outer strncpy flunked for outer = %d, len = %Zd\n",
+ outer, len);
+ result = 1;
+ }
+ }
+ }
+ adr[size-1] = '\0';
+
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (inner = MAX (outer, size - 64); inner < size; ++inner)
+ {
+ size_t len;
+
+ adr[inner] = '\0';
+
+ for (len = 0; len < size - outer + 64; ++len)
+ {
+ if (strncpy (dest, &adr[outer], len) != dest
+ || memcmp (dest, &adr[outer],
+ MIN (inner - outer, len)) != 0
+ || (inner - outer < len
+ && strlen (dest) != (inner - outer)))
+ {
+ printf ("strncpy flunked for outer = %d, inner = %d, len = %Zd\n",
+ outer, inner, len);
+ result = 1;
+ }
+ if (strncpy (dest + 1, &adr[outer], len) != dest + 1
+ || memcmp (dest + 1, &adr[outer],
+ MIN (inner - outer, len)) != 0
+ || (inner - outer < len
+ && strlen (dest + 1) != (inner - outer)))
+ {
+ printf ("strncpy+1 flunked for outer = %d, inner = %d, len = %Zd\n",
+ outer, inner, len);
+ result = 1;
+ }
+ }
+
+ adr[inner] = 'T';
+ }
+ }
+
+#ifndef __FreeBSD__
+ /* stpcpy test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (inner = MAX (outer, size - 64); inner < size; ++inner)
+ {
+ adr[inner] = '\0';
+
+ if ((stpcpy (dest, &adr[outer]) - dest) != inner - outer)
+ {
+ printf ("stpcpy flunked for outer = %d, inner = %d\n",
+ outer, inner);
+ result = 1;
+ }
+
+ adr[inner] = 'T';
+ }
+ }
+
+ /* stpncpy test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ {
+ for (middle = MAX (outer, size - 64); middle < size; ++middle)
+ {
+ adr[middle] = '\0';
+
+ for (inner = 0; inner < size - outer; ++ inner)
+ {
+ if ((stpncpy (dest, &adr[outer], inner) - dest)
+ != MIN (inner, middle - outer))
+ {
+ printf ("stpncpy flunked for outer = %d, middle = %d, "
+ "inner = %d\n", outer, middle, inner);
+ result = 1;
+ }
+ }
+
+ adr[middle] = 'T';
+ }
+ }
+#endif
+
+ /* memcpy test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ for (inner = 0; inner < size - outer; ++inner)
+ if (memcpy (dest, &adr[outer], inner) != dest)
+ {
+ printf ("memcpy flunked for outer = %d, inner = %d\n",
+ outer, inner);
+ result = 1;
+ }
+
+#ifndef __FreeBSD__
+ /* mempcpy test */
+ for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+ for (inner = 0; inner < size - outer; ++inner)
+ if (mempcpy (dest, &adr[outer], inner) != dest + inner)
+ {
+ printf ("mempcpy flunked for outer = %d, inner = %d\n",
+ outer, inner);
+ result = 1;
+ }
+#endif
+ }
+
+ return result;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass1-frag.c b/libmudflap/testsuite/libmudflap.c/pass1-frag.c
new file mode 100644
index 00000000000..40f629b56da
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass1-frag.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int foo [10];
+foo[9] = 0;
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass10-frag.c b/libmudflap/testsuite/libmudflap.c/pass10-frag.c
new file mode 100644
index 00000000000..f05650da515
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass10-frag.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int foo[10];
+int sz = sizeof (int);
+
+char *bar = (char *)foo;
+bar [sz * 9] = 0;
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass11-frag.c b/libmudflap/testsuite/libmudflap.c/pass11-frag.c
new file mode 100644
index 00000000000..ab7ee38c4f8
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass11-frag.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int i = 10;
+char *x = (char *) malloc (i * sizeof (char));
+
+while (--i)
+{
+ ++x;
+ *x = 0;
+}
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass12-frag.c b/libmudflap/testsuite/libmudflap.c/pass12-frag.c
new file mode 100644
index 00000000000..53630d9971d
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass12-frag.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int i = 10;
+int *x = (int *) malloc (i * sizeof (int));
+
+while (--i)
+{
+ ++x;
+ *x = 0;
+}
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass13-frag.c b/libmudflap/testsuite/libmudflap.c/pass13-frag.c
new file mode 100644
index 00000000000..c2b820d0f43
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass13-frag.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct a {
+ int x;
+ int y;
+ char z;
+};
+
+struct a k;
+
+k.z = 'q';
+
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass14-frag.c b/libmudflap/testsuite/libmudflap.c/pass14-frag.c
new file mode 100644
index 00000000000..26456432979
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass14-frag.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct a {
+ int x;
+ int y;
+ char z;
+};
+
+struct a k;
+struct a *p;
+
+p = &k;
+
+p->z = 'q';
+
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass15-frag.c b/libmudflap/testsuite/libmudflap.c/pass15-frag.c
new file mode 100644
index 00000000000..5e1fee8eb9c
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass15-frag.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct base {
+ int basic;
+};
+
+struct derived {
+ struct base common;
+ char extra;
+};
+
+struct derived d;
+struct base *bp;
+
+bp = (struct base *)&d;
+
+bp->basic = 10;
+((struct derived *)bp)->extra = 'x';
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass16-frag.c b/libmudflap/testsuite/libmudflap.c/pass16-frag.c
new file mode 100644
index 00000000000..99ede3f2138
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass16-frag.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct base {
+ int basic;
+};
+
+struct derived {
+ struct base common;
+ char extra;
+};
+
+struct base *bp;
+
+bp = (struct base *) malloc (sizeof (struct derived));
+
+bp->basic = 10;
+((struct derived *)bp)->extra = 'x';
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass17-frag.c b/libmudflap/testsuite/libmudflap.c/pass17-frag.c
new file mode 100644
index 00000000000..b840dc98746
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass17-frag.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+
+strlen("123456789");
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass18-frag.c b/libmudflap/testsuite/libmudflap.c/pass18-frag.c
new file mode 100644
index 00000000000..c5d5af0fe12
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass18-frag.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int t;
+char foo[3] = { 'b', 'c', 'd' };
+int bar[3] = {1, 2, 0};
+t = 1;
+
+/* These tests check expression evaluation rules, such as
+ ensuring that side-effect expression (++) get executed the
+ right number of times; that array lookup checks nest correctly. */
+foo[t++] = 'a';
+if (foo[0] != 'b' || foo[1] != 'a' || foo[2] != 'd' || t != 2) abort ();
+if (bar[0] != 1 || bar[1] != 2 || bar[2] != 0) abort();
+
+foo[bar[t--]] = 'e';
+if (foo[0] != 'e' || foo[1] != 'a' || foo[2] != 'd' || t != 1) abort ();
+if (bar[0] != 1 || bar[1] != 2 || bar[2] != 0) abort();
+
+foo[bar[++t]--] = 'g';
+if (foo[0] != 'g' || foo[1] != 'a' || foo[2] != 'd' || t != 2) abort ();
+if (bar[0] != 1 || bar[1] != 2 || bar[2] != -1) abort();
+
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass19-frag.c b/libmudflap/testsuite/libmudflap.c/pass19-frag.c
new file mode 100644
index 00000000000..0b00845d412
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass19-frag.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct foo {int base; char variable[1]; }; /* a common idiom for variable-size structs */
+
+struct foo * b = (struct foo *) malloc (sizeof (int)); /* enough for base */
+b->base = 4;
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass2-frag.c b/libmudflap/testsuite/libmudflap.c/pass2-frag.c
new file mode 100644
index 00000000000..7e71e0cd7b5
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass2-frag.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int foo [10][10];
+foo[9][0] = 0;
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass20-frag.c b/libmudflap/testsuite/libmudflap.c/pass20-frag.c
new file mode 100644
index 00000000000..98431168548
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass20-frag.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct bar {int stuff; int array[10]; };
+
+struct bar *foo = (struct bar *) malloc (sizeof (struct bar));
+foo->array[5] = 4;
+free (foo);
+
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass21-frag.c b/libmudflap/testsuite/libmudflap.c/pass21-frag.c
new file mode 100644
index 00000000000..231055a236f
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass21-frag.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef __FreeBSD__
+#include <alloca.h>
+#endif
+int main ()
+{
+char *boo, *foo;
+boo = (char *) alloca (100);
+boo[99] = 'a';
+foo = (char *) __builtin_alloca (200);
+foo[44] = 'b';
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass22-frag.c b/libmudflap/testsuite/libmudflap.c/pass22-frag.c
new file mode 100644
index 00000000000..b092ea0b277
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass22-frag.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct foo {
+ unsigned base:8;
+ unsigned flag1:1;
+ unsigned flag2:3;
+ unsigned flag3:4;
+ char nothing[0];
+};
+
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
+
+struct foo* f = (struct foo *) malloc (offsetof (struct foo, nothing));
+f->base = 1;
+f->flag1 = 1;
+free (f);
+
+
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass23-frag.c b/libmudflap/testsuite/libmudflap.c/pass23-frag.c
new file mode 100644
index 00000000000..f27c223614b
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass23-frag.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct foo {
+ int part1: 8;
+ int nothing : 1;
+ int part2 : 5;
+ int lots_more_nothing : 3;
+ int some_padding; /* for 64-bit hosts */
+ float some_more_nothing;
+ double yet_more_nothing;
+};
+
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
+
+struct foo* q = (struct foo *) malloc (offsetof (struct foo, some_more_nothing));
+q->nothing = 1; /* touch q */
+/* The RHS of the following expression is meant to trigger a
+ fold-const.c mapping the expression to a BIT_FIELD_REF. It glues
+ together the accesses to the two non-neighbouring bitfields into a
+ single bigger boolean test. */
+q->lots_more_nothing = (q->part1 == 13 && q->part2 == 7);
+free (q);
+
+
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass24-frag.c b/libmudflap/testsuite/libmudflap.c/pass24-frag.c
new file mode 100644
index 00000000000..00385822130
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass24-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct foo {
+ int zoo;
+ int bar [10];
+ float baz;
+};
+
+#define offsetof(S,F) ((size_t) & (((S *) 0)->F))
+
+struct foo *k = (struct foo *) malloc (offsetof (struct foo, bar[4]));
+k->bar[1] = 9;
+free (k);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass25-frag.c b/libmudflap/testsuite/libmudflap.c/pass25-frag.c
new file mode 100644
index 00000000000..c5a75e3338e
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass25-frag.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int *foo = malloc (10 * sizeof(int));
+int *bar = & foo[3];
+/* Watching occurs at the object granularity, which is in this case
+ the entire array. */
+__mf_watch (& foo[1], sizeof(foo[1]));
+__mf_unwatch (& foo[6], sizeof(foo[6]));
+*bar = 10;
+free (foo);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass26-frag.c b/libmudflap/testsuite/libmudflap.c/pass26-frag.c
new file mode 100644
index 00000000000..5a72f5b790c
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass26-frag.c
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+volatile int *p;
+
+__mf_set_options ("-wipe-stack -no-check-initialization");
+
+{
+ volatile int array [10];
+ p = & array[0];
+
+ array[0] = 2;
+ array[9] = 5;
+
+ /* Array[] should be wiped clean at this point. */
+}
+
+__mf_set_options ("-no-wipe-stack");
+
+{
+ volatile int array2[10];
+
+ /* hope that this is allocated on top of old array[] */
+ if (p != & array2[0])
+ exit (0); /* Test is not applicable. */
+
+ array2[5] = 6;
+
+ /* Old values shouldn't still be around; the new one should. */
+ if (p[0] == 2 || p[9] == 5 || p[5] != 6)
+ abort() ;
+
+ /* array2[] should not be wiped at this point! */
+}
+
+{
+ volatile int array3[10];
+
+ /* hope that this is allocated on top of old array[] and array2[]*/
+ if (p != & array3[0])
+ exit (0); /* Test is not applicable. */
+
+ array3[1] = 2;
+
+ /* Check that old assignment is still around. */
+ if (p[5] != 6 || p[1] != 2)
+ abort() ;
+}
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass29-frag.c b/libmudflap/testsuite/libmudflap.c/pass29-frag.c
new file mode 100644
index 00000000000..97bed6eb373
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass29-frag.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct boo { int a; };
+int c;
+struct boo *b = malloc (sizeof (struct boo));
+__mf_set_options ("-check-initialization");
+b->a = 0;
+/* That __mf_set_options call could be here instead. */
+c = b->a;
+(void) malloc (c); /* some dummy use of c */
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass3-frag.c b/libmudflap/testsuite/libmudflap.c/pass3-frag.c
new file mode 100644
index 00000000000..4e950a2c5d8
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass3-frag.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+int foo [10][10][10];
+foo[9][9][0] = 0;
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass30-frag.c b/libmudflap/testsuite/libmudflap.c/pass30-frag.c
new file mode 100644
index 00000000000..6c4b9f9a7f8
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass30-frag.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char zoo [10];
+
+int main ()
+{
+int i = strlen ("eight") + strlen ("one");
+zoo[i] = 'a';
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass32-frag.c b/libmudflap/testsuite/libmudflap.c/pass32-frag.c
new file mode 100644
index 00000000000..83f121d4fa2
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass32-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct foo { char z[10]; };
+
+char * get_z (struct foo *this)
+{
+ return & this->z[0] /* the `this' pointer is not dereferenced! */;
+}
+
+int main ()
+{
+struct foo k;
+char *n = get_z (& k);
+srand ((int)(uintptr_t) n); /* use the pointer value */
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass33-frag.c b/libmudflap/testsuite/libmudflap.c/pass33-frag.c
new file mode 100644
index 00000000000..95d762cc1aa
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass33-frag.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void test (int *k)
+{
+ if (*k > 5) { *k --; }
+}
+
+int main ()
+{
+int z;
+/* z is initialized, but not via a pointer, so not instrumented */
+z = rand ();
+test (& z);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass34-frag.c b/libmudflap/testsuite/libmudflap.c/pass34-frag.c
new file mode 100644
index 00000000000..2dfd0ca2113
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass34-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void test (int *k)
+{
+ if (*k > 5) { *k --; }
+}
+
+int z;
+
+int main ()
+{
+/* z is initialized, but not via a pointer, so not instrumented */
+z = rand ();
+test (& z);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass35-frag.c b/libmudflap/testsuite/libmudflap.c/pass35-frag.c
new file mode 100644
index 00000000000..4744ecdbe99
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass35-frag.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern char end []; /* Any old symbol we're sure will be defined. */
+/* { dg-warning "cannot track lifetime of `end'" "cannot track lifetime" { target *-*-* } 0 } */
+
+int main ()
+{
+/* dummy register */
+__mf_register ((void *) end, 1, __MF_TYPE_GUESS, "end");
+char z = end[0];
+return z & 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass36-frag.c b/libmudflap/testsuite/libmudflap.c/pass36-frag.c
new file mode 100644
index 00000000000..68d1a7f8080
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass36-frag.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+int main ()
+{
+char *k;
+__mf_set_options ("-sigusr1-report -print-leaks");
+k = (char *) malloc (100);
+raise (SIGUSR1);
+free (k);
+return 0;
+}
+/* { dg-output "Leaked object.*name=.malloc region.*objects: 1" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass38-frag.c b/libmudflap/testsuite/libmudflap.c/pass38-frag.c
new file mode 100644
index 00000000000..a250234da8a
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass38-frag.c
@@ -0,0 +1,9 @@
+/* Test an odd construct for compilability. */
+static void *fwd;
+void *bwd = &fwd;
+static void *fwd = &bwd;
+
+int main ()
+{
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass4-frag.c b/libmudflap/testsuite/libmudflap.c/pass4-frag.c
new file mode 100644
index 00000000000..0a40d1c425a
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass4-frag.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char foo[10];
+strcpy (foo, "123456789");
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass42-frag.c b/libmudflap/testsuite/libmudflap.c/pass42-frag.c
new file mode 100644
index 00000000000..1045c47c37a
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass42-frag.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+void
+foo ()
+{
+ putc ('h', stdout);
+ putc ('i', stdout);
+ putc ('\n', stdout);
+}
+
+int
+main (int argc, char *argv[])
+{
+ foo ();
+ return 0;
+}
+/* { dg-output "hi" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass43-frag.c b/libmudflap/testsuite/libmudflap.c/pass43-frag.c
new file mode 100644
index 00000000000..4fec3306eb1
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass43-frag.c
@@ -0,0 +1,11 @@
+void
+foo ()
+{
+}
+
+int
+main (int argc, char *argv[])
+{
+ foo ();
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass44-frag.c b/libmudflap/testsuite/libmudflap.c/pass44-frag.c
new file mode 100644
index 00000000000..338d6da63bf
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass44-frag.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+void
+foo ()
+{
+ return; /* accept value-less return statement */
+}
+
+int
+main (int argc, char *argv[])
+{
+ foo ();
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass45-frag.c b/libmudflap/testsuite/libmudflap.c/pass45-frag.c
new file mode 100644
index 00000000000..c6bfeb5048c
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass45-frag.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern void h (const char *p, const char *f);
+int
+main (void)
+{
+ h (0, "foo");
+ return 0;
+}
+
+void
+h (const char *p, const char *f)
+{
+ size_t pl = p == NULL ? 0 : strlen (p);
+ size_t fl = strlen (f) + 1;
+ char a[pl + 1 + fl];
+ char *cp = a;
+ char b[pl + 5 + fl * 2];
+ char *cccp = b;
+ if (p != NULL)
+ {
+ cp = memcpy (cp, p, pl);
+ *cp++ = ':';
+ }
+ memcpy (cp, f, fl);
+ strcpy (b, a);
+ puts (a);
+}
+/* { dg-output "foo" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass46-frag.c b/libmudflap/testsuite/libmudflap.c/pass46-frag.c
new file mode 100644
index 00000000000..a1f24be1dc0
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass46-frag.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int foo (int *u, int i)
+{
+ return u[i]; /* this dereference should not be instrumented */
+}
+
+int main ()
+{
+ int *k = malloc (6);
+ int l = foo (k, 8);
+ int boo [8];
+ int m = boo [l % 2 + 12]; /* should not be instrumented */
+ return m & strlen (""); /* a fancy way of saying "0" */
+}
+/* { dg-options "-fmudflap -fmudflapir -Wall" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass5-frag.c b/libmudflap/testsuite/libmudflap.c/pass5-frag.c
new file mode 100644
index 00000000000..6d3408a4e52
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass5-frag.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char foo [10];
+char bar [10];
+bar[4] = 'k'; /* touch memcpy source */
+memcpy(foo, bar, 10);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass6-frag.c b/libmudflap/testsuite/libmudflap.c/pass6-frag.c
new file mode 100644
index 00000000000..9b07fe2de22
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass6-frag.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+bar[2] = 'z'; /* touch memcpy source */
+memcpy(foo, bar, 10);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass7-frag.c b/libmudflap/testsuite/libmudflap.c/pass7-frag.c
new file mode 100644
index 00000000000..36197339e88
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass7-frag.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+bar[2] = 'z'; /* touch memcpy source */
+memcpy(foo+1, bar+1, 9);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass8-frag.c b/libmudflap/testsuite/libmudflap.c/pass8-frag.c
new file mode 100644
index 00000000000..6be4e93f000
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass8-frag.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(bar);
+bar = (char *)malloc (10);
+bar[6] = 'k'; /* touch memcpy source */
+memcpy(foo, bar, 10);
+return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass9-frag.c b/libmudflap/testsuite/libmudflap.c/pass9-frag.c
new file mode 100644
index 00000000000..9186e062ff8
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass9-frag.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(foo);
+foo = (char *)malloc (10);
+bar[3] = 'w'; /* touch memcpy source */
+memcpy(foo, bar, 10);
+return 0;
+}