diff options
Diffstat (limited to 'libmudflap')
-rw-r--r-- | libmudflap/ChangeLog | 6 | ||||
-rw-r--r-- | libmudflap/testsuite/libmudflap.c/fail35-frag.c | 23 | ||||
-rw-r--r-- | libmudflap/testsuite/libmudflap.c/pass35-frag.c | 2 | ||||
-rw-r--r-- | libmudflap/testsuite/libmudflap.c/pass53-frag.c | 41 | ||||
-rw-r--r-- | libmudflap/testsuite/libmudflap.c/pass54-frag.c | 33 |
5 files changed, 104 insertions, 1 deletions
diff --git a/libmudflap/ChangeLog b/libmudflap/ChangeLog index ffb681e..b437bc4 100644 --- a/libmudflap/ChangeLog +++ b/libmudflap/ChangeLog @@ -1,3 +1,9 @@ +2004-10-28 Frank Ch. Eigler <fche@redhat.com> + + * testsuite/libmudflap.c/fail35-,pass53-,pass54-frag.c: New tests. + * testsuite/libmudflap.c/pass35-frag.c: Correct embedded warning + message. + 2004-10-25 Eric Botcazou <ebotcazou@libertysurf.fr> PR other/18138 diff --git a/libmudflap/testsuite/libmudflap.c/fail35-frag.c b/libmudflap/testsuite/libmudflap.c/fail35-frag.c new file mode 100644 index 0000000..101fe29 --- /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 95dafab..14d2c94 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 0000000..6afb293 --- /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 0000000..59cf2fa --- /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"); +} |