summaryrefslogtreecommitdiffstats
path: root/libmudflap/testsuite
diff options
context:
space:
mode:
authorfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-28 21:21:59 +0000
committerfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-28 21:21:59 +0000
commit3fd378a3b2e8e8d2ea9645c6664b8d7d38110b8c (patch)
tree05f8dd75d157d8ee718e6ed7ac4ee5022718a104 /libmudflap/testsuite
parentc85df9ac2ac1f38a34922276d563641e40eb41fa (diff)
downloadppe42-gcc-3fd378a3b2e8e8d2ea9645c6664b8d7d38110b8c.tar.gz
ppe42-gcc-3fd378a3b2e8e8d2ea9645c6664b8d7d38110b8c.zip
2004-10-28 Frank Ch. Eigler <fche@redhat.com>
* testsuite/libmudflap.c/fail35-,pass53-,pass54-frag.c: New tests. * testsuite/libmudflap.c/pass35-frag.c: Correct embedded warning message. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89783 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libmudflap/testsuite')
-rw-r--r--libmudflap/testsuite/libmudflap.c/fail35-frag.c23
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass35-frag.c2
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass53-frag.c41
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass54-frag.c33
4 files changed, 98 insertions, 1 deletions
diff --git a/libmudflap/testsuite/libmudflap.c/fail35-frag.c b/libmudflap/testsuite/libmudflap.c/fail35-frag.c
new file mode 100644
index 00000000000..101fe293b2b
--- /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/pass35-frag.c b/libmudflap/testsuite/libmudflap.c/pass35-frag.c
index 95dafab836d..14d2c94a9bb 100644
--- a/libmudflap/testsuite/libmudflap.c/pass35-frag.c
+++ b/libmudflap/testsuite/libmudflap.c/pass35-frag.c
@@ -3,7 +3,7 @@
#include <string.h>
extern char end []; /* Any old symbol we're sure will be defined. */
-/* { dg-warning "cannot track unknown size extern 'end'" "cannot track unknown size extern" { target *-*-* } 0 } */
+/* { dg-warning "cannot track unknown size extern" "cannot track unknown size extern" { target *-*-* } 0 } */
int main ()
{
diff --git a/libmudflap/testsuite/libmudflap.c/pass53-frag.c b/libmudflap/testsuite/libmudflap.c/pass53-frag.c
new file mode 100644
index 00000000000..6afb2931e34
--- /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 00000000000..59cf2fa6258
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass54-frag.c
@@ -0,0 +1,33 @@
+struct k
+{
+ struct {
+ int b;
+ int c;
+ } a;
+};
+
+static struct k l;
+static struct k m;
+
+void foo ()
+{
+ /* This should not be instrumented. */
+ l.a.b = 5;
+}
+
+void bar ()
+{
+ /* This should not be instrumented. */
+ m.a.b = 5;
+}
+
+int main ()
+{
+ /* Force TREE_ADDRESSABLE on "l" only. */
+ volatile int *k = & l.a.c;
+ *k = 8;
+ __mf_set_options ("-mode-violate");
+ foo ();
+ bar ();
+ __mf_set_options ("-mode-check");
+}
OpenPOWER on IntegriCloud