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.exp21
-rw-r--r--libmudflap/testsuite/libmudflap.c/externs-1.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/externs-2.c2
-rw-r--r--libmudflap/testsuite/libmudflap.c/externs.exp43
-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.c20
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail12-frag.c20
-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.c27
-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.c23
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail32-frag.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail33-frag.c25
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail34-frag.c22
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail35-frag.c23
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail36-frag.c23
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail37-frag.c22
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail38-frag.c29
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail39-frag.c20
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail4-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail40-frag.c59
-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/fail68-frag.c27
-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/heap-scalestress.c79
-rw-r--r--libmudflap/testsuite/libmudflap.c/hook-allocstuff.c16
-rw-r--r--libmudflap/testsuite/libmudflap.c/hook2-allocstuff.c9
-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/pass47-frag.c10
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass48-frag.c11
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass49-frag.c35
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass5-frag.c11
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass50-frag.c29
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass51-frag.c44
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass52-frag.c36
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass53-frag.c41
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass54-frag.c34
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass56-frag.c14
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass6-frag.c14
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass62-frag.c13
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass63-frag.c6
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass64-frag.c38
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass67-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
100 files changed, 2310 insertions, 0 deletions
diff --git a/libmudflap/testsuite/libmudflap.c/cfrags.exp b/libmudflap/testsuite/libmudflap.c/cfrags.exp
new file mode 100644
index 000000000..bdaf2196c
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/cfrags.exp
@@ -0,0 +1,21 @@
+global MUDFLAP_FLAGS
+set MUDFLAP_FLAGS [list {} {-static} {-O2} {-O3}]
+
+libmudflap-init c
+
+dg-init
+
+global srcdir
+foreach flags $MUDFLAP_FLAGS {
+ foreach srcfile [lsort [glob -nocomplain \
+ ${srcdir}/libmudflap.c/*frag.c \
+ ${srcdir}/libmudflap.c/heap*.c \
+ ${srcdir}/libmudflap.c/hook*.c \
+ ${srcdir}/libmudflap.c/pass*.c]] {
+ set bsrc [file tail $srcfile]
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+ dg-runtest $srcfile $flags "-fmudflap -lmudflap"
+ }
+}
+
+dg-finish
diff --git a/libmudflap/testsuite/libmudflap.c/externs-1.c b/libmudflap/testsuite/libmudflap.c/externs-1.c
new file mode 100644
index 000000000..028f5eb5a
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/externs-1.c
@@ -0,0 +1,16 @@
+typedef struct { char *name; } dummy;
+extern dummy d[];
+
+int
+main (void)
+{
+ dummy *pd = d;
+
+ while (pd->name)
+ {
+ printf ("%s\n", pd->name);
+ pd++;
+ }
+
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/externs-2.c b/libmudflap/testsuite/libmudflap.c/externs-2.c
new file mode 100644
index 000000000..cecf6253a
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/externs-2.c
@@ -0,0 +1,2 @@
+typedef struct { char *name; } dummy;
+dummy d[] = { {"a"}, {0} };
diff --git a/libmudflap/testsuite/libmudflap.c/externs.exp b/libmudflap/testsuite/libmudflap.c/externs.exp
new file mode 100644
index 000000000..773f80cc1
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/externs.exp
@@ -0,0 +1,43 @@
+global MUDFLAP_FLAGS
+set MUDFLAP_FLAGS [list {} {-static} {-O2} {-O3}]
+
+libmudflap-init c
+dg-init
+
+global srcdir subdir
+
+foreach flags $MUDFLAP_FLAGS {
+ set l1 [libmudflap_target_compile "$srcdir/$subdir/externs-1.c" "externs-1.o" object {additional_flags=-fmudflap}]
+ set test "externs-1 compilation ${flags}"
+ if [string match "*mudflap cannot track unknown size extern *d*" $l1] { pass $test } { fail $test }
+
+ set l2 [libmudflap_target_compile "$srcdir/$subdir/externs-2.c" "externs-2.o" object {additional_flags=-fmudflap}]
+ set test "externs-2 compilation ${flags}"
+ if [string match "" $l2] { pass $test } { fail $test }
+
+ set l3 [libmudflap_target_compile "externs-1.o externs-2.o" "externs-12.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}]
+ set test "externs-12 linkage ${flags}"
+ if [string match "" $l3] { pass $test } { fail $test }
+
+ set l4 [libmudflap_target_compile "externs-2.o externs-1.o" "externs-21.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}]
+ set test "externs-21 linkage ${flags}"
+ if [string match "" $l3] { pass $test } { fail $test }
+
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+
+ remote_spawn host "./externs-12.exe"
+ set l5 [remote_wait host 10]
+ set test "externs-12 execution ${flags}"
+ if {[lindex $l5 0] == 0} { pass $test } { fail $test }
+
+ remote_spawn host "./externs-21.exe"
+ set l6 [remote_wait host 10]
+ set test "externs-21 execution ${flags}"
+ if {[lindex $l6 0] == 0} { pass $test } { fail $test }
+
+ foreach f [glob -nocomplain "externs-*"] {
+ remote_file build delete $f
+ }
+}
+
+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 000000000..1e48fff87
--- /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 000000000..db135d5c4
--- /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 000000000..ebd1db967
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail11-frag.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+char *y;
+int main ()
+{
+int i = 10;
+char *x = (char *) malloc (i * sizeof (char));
+y = x;
+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 000000000..46dbdb236
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail12-frag.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int *y;
+int main ()
+{
+int i = 10;
+int *x = (int *) malloc (i * sizeof (int));
+y = x;
+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 000000000..9fd3e2557
--- /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 000000000..e66cc94c4
--- /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 000000000..5d7ae7449
--- /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 000000000..6ac6187e2
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail16-frag.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+void *p;
+int main ()
+{
+struct base {
+ int basic;
+};
+
+struct derived {
+ struct base common;
+ char extra;
+};
+
+struct base *bp;
+
+bp = (struct base *) malloc (sizeof (struct base));;
+p = bp;
+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 000000000..5af67f138
--- /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 000000000..a7b62ddb7
--- /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 * volatile 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 000000000..7e446b405
--- /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 000000000..7672e60c6
--- /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 000000000..0dd8bb7f9
--- /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 000000000..4ab4a09f3
--- /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 000000000..7dd7103d3
--- /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 000000000..bb1b52ec7
--- /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 000000000..acac5236b
--- /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 000000000..88484d6ad
--- /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 000000000..547c5e7a6
--- /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 dead 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 000000000..7d61c57f3
--- /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 000000000..2024064dc
--- /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 000000000..98c1dbae1
--- /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 000000000..8bfea61cb
--- /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 000000000..bd9a903cc
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail31-frag.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int h (int i, int j);
+
+int main ()
+{
+ int z = h (4, 10);
+ return 0;
+}
+int *p;
+int h (int i, int j)
+{
+ int k[i];
+ k[j] = i;
+ p = k;
+ 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/fail32-frag.c b/libmudflap/testsuite/libmudflap.c/fail32-frag.c
new file mode 100644
index 000000000..2a38237b6
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail32-frag.c
@@ -0,0 +1,16 @@
+void foo (int k)
+{
+ volatile int *b = & k;
+ b++;
+ *b = 5;
+}
+
+int main ()
+{
+ foo (5);
+ return 0;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*k" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail33-frag.c b/libmudflap/testsuite/libmudflap.c/fail33-frag.c
new file mode 100644
index 000000000..ac7c617a4
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail33-frag.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+
+#define SIZE 16
+
+char b[SIZE];
+char a[SIZE];
+
+int main ()
+{
+ int i, j=0, k;
+ int a_before_b = (& a[0] < & b[0]);
+ /* Rather than iterating linearly, which would allow loop unrolling
+ and mapping to pointer manipulation, we traverse the "joined"
+ arrays in some random order. */
+ for (i=0; i<SIZE*2; i++)
+ {
+ k = rand() % (SIZE*2);
+ j += (a_before_b ? a[k] : b[k]);
+ }
+ return j;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*\[ab\]" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail34-frag.c b/libmudflap/testsuite/libmudflap.c/fail34-frag.c
new file mode 100644
index 000000000..f6572b019
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail34-frag.c
@@ -0,0 +1,22 @@
+#include <stdlib.h>
+
+struct s
+{
+ int a1[4];
+};
+
+struct s a, b;
+int idx = 7; /* should pass to the next object */
+
+int
+main ()
+{
+ int i, j=0;
+ int a_before_b = (& a < & b);
+ j = (a_before_b ? a.a1[idx] : b.a1[idx]);
+ return j;
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.*\[ab\]" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail35-frag.c b/libmudflap/testsuite/libmudflap.c/fail35-frag.c
new file mode 100644
index 000000000..101fe293b
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail35-frag.c
@@ -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 *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail36-frag.c b/libmudflap/testsuite/libmudflap.c/fail36-frag.c
new file mode 100644
index 000000000..af6851c1d
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail36-frag.c
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+
+struct k
+{
+ int p;
+ struct {
+ int m : 31;
+ } 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
+ BIT_FIELD_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 *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail37-frag.c b/libmudflap/testsuite/libmudflap.c/fail37-frag.c
new file mode 100644
index 000000000..41ce4b91e
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail37-frag.c
@@ -0,0 +1,22 @@
+typedef struct
+{
+ short f : 3;
+} small;
+
+struct
+{
+ int i;
+ small s[4];
+} x;
+
+main ()
+{
+ int i;
+ for (i = 0; i < 5; i++)
+ x.s[i].f = 0;
+ exit (0);
+}
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object.*" } */
+/* { dg-output "mudflap object.* x.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/fail38-frag.c b/libmudflap/testsuite/libmudflap.c/fail38-frag.c
new file mode 100644
index 000000000..9667e2134
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail38-frag.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main ()
+{
+struct a {
+ int x;
+ int y;
+ int z : 10;
+};
+
+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/fail39-frag.c b/libmudflap/testsuite/libmudflap.c/fail39-frag.c
new file mode 100644
index 000000000..4e74ea5cd
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail39-frag.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main ()
+{
+ volatile int *k = (int *) malloc (sizeof (int));
+ volatile int l;
+ if (k == NULL) abort ();
+ *k = 5;
+ free ((void *) k);
+ __mf_set_options ("-ignore-reads");
+ l = *k; /* Should not trip, even though memory region just freed. */
+ __mf_set_options ("-no-ignore-reads");
+ l = *k; /* Should trip now. */
+ return 0;
+}
+/* { dg-output "mudflap violation 1.*check/read.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap dead object.*malloc region.*" } */
+/* { 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 000000000..a3423e6c3
--- /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/fail40-frag.c b/libmudflap/testsuite/libmudflap.c/fail40-frag.c
new file mode 100644
index 000000000..fbeb6fd21
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail40-frag.c
@@ -0,0 +1,59 @@
+/* Test proper lookup-uncaching of large objects */
+#include "../config.h"
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+int main ()
+{
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+#ifdef HAVE_MMAP
+ volatile unsigned char *p;
+ unsigned num = getpagesize ();
+ unsigned i;
+ int rc;
+
+ /* Get a bit of usable address space. We really want an 2**N+1-sized object,
+ so the low/high addresses wrap when hashed into the lookup cache. So we
+ will manually unregister the entire mmap, then re-register a slice. */
+ p = mmap (NULL, num, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (p == MAP_FAILED)
+ return 1;
+ /* Now unregister it, as if munmap was called. But don't actually munmap, so
+ we can write into the memory. */
+ __mf_unregister ((void *) p, num, __MF_TYPE_HEAP_I);
+
+ /* Now register it under a slightly inflated, 2**N+1 size. */
+ __mf_register ((void *) p, num+1, __MF_TYPE_HEAP_I, "fake mmap registration");
+
+ /* Traverse array to ensure that entire lookup cache is made to point at it. */
+ for (i=0; i<num; i++)
+ p[i] = 0;
+
+ /* Unregister it. This should clear the entire lookup cache, even though
+ hash(low) == hash (high) (and probably == 0) */
+ __mf_unregister ((void *) p, num+1, __MF_TYPE_HEAP_I);
+
+ /* Now touch the middle portion of the ex-array. If the lookup cache was
+ well and truly cleaned, then this access should trap. */
+ p[num/2] = 1;
+
+ return 0;
+#else
+ return 1;
+#endif
+}
+/* { dg-output "mudflap violation 1.*check/write.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap dead object.*fake mmap registration.*" } */
+/* { 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 000000000..a08569fe7
--- /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 000000000..1904a8871
--- /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/fail68-frag.c b/libmudflap/testsuite/libmudflap.c/fail68-frag.c
new file mode 100644
index 000000000..7b2f8cf2c
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/fail68-frag.c
@@ -0,0 +1,27 @@
+/* PR libmudflap/40778 */
+
+char p[32];
+static int j;
+
+__attribute__((noinline))
+static void foo (int i)
+{
+ if (j++ == 0)
+ p[i + 4] = 12;
+ else
+ p[i - 4] = 13;
+}
+
+int
+main ()
+{
+ foo (30);
+ foo (30);
+ foo (30);
+ return 0;
+}
+
+/* { dg-output "mudflap violation 1.*" } */
+/* { dg-output "Nearby object 1.*" } */
+/* { dg-output "mudflap object.*name.*p" } */
+/* { 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 000000000..580d04538
--- /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 000000000..8309068df
--- /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 dead 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 000000000..9bbd860a8
--- /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 dead object.*malloc region.*alloc time.*dealloc time.*" } */
+/* { dg-do run { xfail *-*-* } } */
diff --git a/libmudflap/testsuite/libmudflap.c/heap-scalestress.c b/libmudflap/testsuite/libmudflap.c/heap-scalestress.c
new file mode 100644
index 000000000..2d51731d6
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/heap-scalestress.c
@@ -0,0 +1,79 @@
+/* zz30
+ *
+ * demonstrate a splay-tree depth problem
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#ifndef SCALE
+#define SCALE 100000
+#endif
+
+
+struct list
+{
+ struct list *next;
+};
+
+
+int
+main ()
+{
+ struct list *head = NULL;
+ struct list *tail = NULL;
+ struct list *p;
+ long n;
+ int direction;
+
+ for (direction = 0; direction < 2; direction++)
+ {
+ fprintf (stdout, "allocating\n");
+ fflush (stdout);
+
+ for (n = 0; n < SCALE; ++n)
+ {
+ p = malloc (sizeof *p);
+ if (NULL == p)
+ {
+ fprintf (stdout, "malloc failed\n");
+ break;
+ }
+ if (direction == 0)
+ { /* add at tail */
+ p->next = NULL;
+ if (NULL != tail)
+ tail->next = p;
+ else
+ head = p;
+ tail = p;
+ }
+ else
+ { /* add at head */
+ p->next = head;
+ if (NULL == tail)
+ tail = p;
+ head = p;
+ }
+ }
+
+ fprintf (stdout, "freeing\n");
+ fflush (stdout);
+
+ while (NULL != head)
+ {
+ p = head;
+ head = head->next;
+ free (p);
+ }
+
+ }
+
+ fprintf (stdout, "done\n");
+ fflush (stdout);
+
+ return (0);
+}
+
+/* { dg-output "allocating.*freeing.*allocating.*freeing.*done" } */
diff --git a/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c b/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c
new file mode 100644
index 000000000..dc2537548
--- /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/hook2-allocstuff.c b/libmudflap/testsuite/libmudflap.c/hook2-allocstuff.c
new file mode 100644
index 000000000..d8fbec467
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/hook2-allocstuff.c
@@ -0,0 +1,9 @@
+/* Generates recursive malloc call on i386-freebsd4.10 with -fmudflap. */
+#include <stdlib.h>
+
+int
+main (void)
+{
+ char *p = malloc (1<<24);
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c b/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c
new file mode 100644
index 000000000..baaf8a9f3
--- /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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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 000000000..40f629b56
--- /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 000000000..f05650da5
--- /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 000000000..ab7ee38c4
--- /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 000000000..53630d997
--- /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 000000000..c2b820d0f
--- /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 000000000..264564329
--- /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 000000000..5e1fee8eb
--- /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 000000000..99ede3f21
--- /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 000000000..b840dc987
--- /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 000000000..c5d5af0fe
--- /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 000000000..0b00845d4
--- /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 000000000..7e71e0cd7
--- /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 000000000..984311685
--- /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 000000000..231055a23
--- /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 000000000..b092ea0b2
--- /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 000000000..f27c22361
--- /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 000000000..003858221
--- /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 000000000..c5a75e333
--- /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 000000000..5a72f5b79
--- /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 000000000..97bed6eb3
--- /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 000000000..4e950a2c5
--- /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 000000000..6c4b9f9a7
--- /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 000000000..d7f223279
--- /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)(__mf_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 000000000..95d762cc1
--- /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 000000000..2dfd0ca21
--- /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 000000000..14d2c94a9
--- /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 unknown size extern" "cannot track unknown size extern" { 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 000000000..68d1a7f80
--- /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 000000000..a250234da
--- /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 000000000..0a40d1c42
--- /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 000000000..1045c47c3
--- /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 000000000..4fec3306e
--- /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 000000000..338d6da63
--- /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 000000000..c6bfeb504
--- /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 000000000..904868af0
--- /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 -lmudflap" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass47-frag.c b/libmudflap/testsuite/libmudflap.c/pass47-frag.c
new file mode 100644
index 000000000..9e4ac50ef
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass47-frag.c
@@ -0,0 +1,10 @@
+#include <stdlib.h>
+#include <ctype.h>
+
+int main ()
+{
+ char* buf = "hello";
+ return ! ((toupper (buf[0]) == 'H' && toupper ('z') == 'Z' &&
+ tolower (buf[4]) == 'o' && tolower ('X') == 'x' &&
+ isdigit (buf[3])) == 0 && isalnum ('4'));
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass48-frag.c b/libmudflap/testsuite/libmudflap.c/pass48-frag.c
new file mode 100644
index 000000000..3059762a8
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass48-frag.c
@@ -0,0 +1,11 @@
+void foo (int k)
+{
+ volatile int *b = & k;
+ *b = 5;
+}
+
+int main ()
+{
+ foo (5);
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass49-frag.c b/libmudflap/testsuite/libmudflap.c/pass49-frag.c
new file mode 100644
index 000000000..db7453079
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass49-frag.c
@@ -0,0 +1,35 @@
+#include <stdlib.h>
+#include <ctype.h>
+#include <stdarg.h>
+
+int foo (int a, ...)
+{
+ va_list args;
+ char *a1;
+ int a2;
+ int k;
+
+ va_start (args, a);
+ for (k = 0; k < a; k++)
+ {
+ if ((k % 2) == 0)
+ {
+ char *b = va_arg (args, char *);
+ printf ("%s", b);
+ }
+ else
+ {
+ int b = va_arg (args, int);
+ printf ("%d", b);
+ }
+ }
+ va_end (args);
+ return a;
+}
+
+int main ()
+{
+ foo (7, "hello ", 5, " ", 3, " world ", 9, "\n");
+ return 0;
+}
+/* { dg-output "hello 5 3 world 9" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass5-frag.c b/libmudflap/testsuite/libmudflap.c/pass5-frag.c
new file mode 100644
index 000000000..6d3408a4e
--- /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/pass50-frag.c b/libmudflap/testsuite/libmudflap.c/pass50-frag.c
new file mode 100644
index 000000000..ac9ee0909
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass50-frag.c
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+
+struct a
+{
+ int a1[5];
+ union
+ {
+ int b1[5];
+ struct
+ {
+ int c1;
+ int c2;
+ } b2[4];
+ } a2[8];
+};
+
+int i1 = 5;
+int i2 = 2;
+int i3 = 6;
+int i4 = 0;
+
+int
+main ()
+{
+ volatile struct a *k = calloc (1, sizeof (struct a));
+ k->a2[i1].b1[i2] = k->a2[i3].b2[i4].c2;
+ free ((void *) k);
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass51-frag.c b/libmudflap/testsuite/libmudflap.c/pass51-frag.c
new file mode 100644
index 000000000..2780ffd72
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass51-frag.c
@@ -0,0 +1,44 @@
+/* Test object-spanning accesses. This is most conveniently done with
+ mmap, thus the config.h specificity here. */
+#include "../config.h"
+
+#include <unistd.h>
+#include <string.h>
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+int main ()
+{
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+#ifdef HAVE_MMAP
+ void *p;
+ unsigned pg = getpagesize ();
+ int rc;
+
+ p = mmap (NULL, 4 * pg, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (p == MAP_FAILED)
+ return 1;
+
+ memset (p, 0, 4*pg);
+ rc = munmap (p, pg);
+ if (rc < 0) return 1;
+ memset (p+pg, 0, 3*pg);
+ rc = munmap (p+pg, pg);
+ if (rc < 0) return 1;
+ memset (p+2*pg, 0, 2*pg);
+ rc = munmap (p+2*pg, pg);
+ if (rc < 0) return 1;
+ memset (p+3*pg, 0, pg);
+ rc = munmap (p+3*pg, pg);
+ if (rc < 0) return 1;
+#endif
+
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass52-frag.c b/libmudflap/testsuite/libmudflap.c/pass52-frag.c
new file mode 100644
index 000000000..7ff9d577b
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass52-frag.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+
+
+void writestuff (FILE *f)
+{
+ fprintf (f, "hello world\n");
+ fputc ('y', f);
+ putc ('e', f);
+}
+
+void readstuff (FILE *f)
+{
+ int c, d;
+ char stuff[100], *s;
+ c = fgetc (f);
+ ungetc (c, f);
+ d = fgetc (f);
+ s = fgets (stuff, sizeof(stuff), f);
+}
+
+int main ()
+{
+ FILE *f;
+ writestuff (stdout);
+ writestuff (stderr);
+ f = fopen ("/dev/null", "w");
+ writestuff (f);
+ fclose (f);
+ f = fopen ("/dev/zero", "r");
+ readstuff (f);
+ f = freopen ("/dev/null", "w", f);
+ writestuff (f);
+ fclose (f);
+
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass53-frag.c b/libmudflap/testsuite/libmudflap.c/pass53-frag.c
new file mode 100644
index 000000000..6afb2931e
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass53-frag.c
@@ -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
index 000000000..5eebb4515
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass54-frag.c
@@ -0,0 +1,34 @@
+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");
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass56-frag.c b/libmudflap/testsuite/libmudflap.c/pass56-frag.c
new file mode 100644
index 000000000..e22fc8dbf
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass56-frag.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main ()
+{
+ volatile int *k = (int *) malloc (sizeof (int));
+ volatile int l;
+ if (k == NULL) abort ();
+ *k = 5;
+ free ((void *) k);
+ __mf_set_options ("-ignore-reads");
+ l = *k; /* Should not trip, even though memory region just freed. */
+ 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 000000000..9b07fe2de
--- /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/pass62-frag.c b/libmudflap/testsuite/libmudflap.c/pass62-frag.c
new file mode 100644
index 000000000..8e64b2b0e
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass62-frag.c
@@ -0,0 +1,13 @@
+/* PR tree-optimization/34618 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fmudflap" } */
+
+int a[16];
+
+void
+foo ()
+{
+ int i;
+ for (i = 0; i < 16; i++)
+ a[i] = i;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass63-frag.c b/libmudflap/testsuite/libmudflap.c/pass63-frag.c
new file mode 100644
index 000000000..a5ad8f26b
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass63-frag.c
@@ -0,0 +1,6 @@
+/* Check -Wno-mudflap flag */
+/* { dg-do compile } */
+/* { dg-options "-fmudflap -Wno-mudflap" } */
+
+extern char x[];
+int main() { return x[3]; } /* { dg-bogus "mudflap cannot track" } */
diff --git a/libmudflap/testsuite/libmudflap.c/pass64-frag.c b/libmudflap/testsuite/libmudflap.c/pass64-frag.c
new file mode 100644
index 000000000..856eec0fa
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass64-frag.c
@@ -0,0 +1,38 @@
+/* PR libmudflap/36397 */
+/* { dg-do run } */
+/* { dg-options "-O -fmudflap -fno-strict-aliasing -lmudflap" } */
+
+struct A
+{
+ int a[2];
+};
+
+long long int x;
+
+int __attribute__ ((noinline))
+baz (long long int *x)
+{
+ return *x;
+}
+
+int __attribute__ ((noinline))
+foo (int i)
+{
+ if (i > 10)
+ return baz (&x);
+ return ((struct A *) &x)->a[i];
+}
+
+int
+main (void)
+{
+ if (sizeof (long long) == 2 * sizeof (int)
+ && sizeof (long long) == sizeof (struct A))
+ {
+ struct A a = { .a[0] = 10, .a[1] = 20 };
+ __builtin_memcpy (&x, &a, sizeof (x));
+ if (foo (0) != 10 || foo (1) != 20)
+ __builtin_abort ();
+ }
+ return 0;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass67-frag.c b/libmudflap/testsuite/libmudflap.c/pass67-frag.c
new file mode 100644
index 000000000..0c2f81a17
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass67-frag.c
@@ -0,0 +1,14 @@
+/* PR middle-end/35314 */
+/* { dg-do compile } */
+/* { dg-options "-fmudflap" } */
+
+#include <setjmp.h>
+
+jmp_buf buf;
+
+void
+foo (volatile char *p)
+{
+ if (__builtin_setjmp (buf))
+ *p;
+}
diff --git a/libmudflap/testsuite/libmudflap.c/pass7-frag.c b/libmudflap/testsuite/libmudflap.c/pass7-frag.c
new file mode 100644
index 000000000..36197339e
--- /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 000000000..6be4e93f0
--- /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 000000000..9186e062f
--- /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;
+}