diff options
author | fche <fche@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-02 23:12:49 +0000 |
---|---|---|
committer | fche <fche@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-02 23:12:49 +0000 |
commit | 5df46b5217b39abadd8d1dbacdb13482bbe57d30 (patch) | |
tree | 34af220a8005039a10395e1129f99324b64ce2ae /libmudflap | |
parent | 5a6aa39e1b2f6146fd133d6b851a920a74804959 (diff) | |
download | gcc-5df46b5217b39abadd8d1dbacdb13482bbe57d30.tar.gz |
2004-10-02 Frank Ch. Eigler <fche@redhat.com>
* tree-mudflap.c (mf_build_check_statement_for): Reorganize to
take check-base and -limit arguments.
(mf_xform_derefs_1): Reorganize slightly to pass proper base/limit
check ranges for ARRAY_REF and COMPONENT_REF.
(execute_mudflap_fnction_ops, ..._decls): Limit unnecessary
instrumentation.
2004-10-02 Frank Ch. Eigler <fche@redhat.com>
* testsuite/libmudflap.c/pass50-frag.c, fail33-frag.c, fail34-frag.c:
New tests for proper base/limit checking for aggregates.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88432 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libmudflap')
-rw-r--r-- | libmudflap/ChangeLog | 5 | ||||
-rw-r--r-- | libmudflap/testsuite/libmudflap.c/fail33-frag.c | 25 | ||||
-rw-r--r-- | libmudflap/testsuite/libmudflap.c/fail34-frag.c | 22 | ||||
-rw-r--r-- | libmudflap/testsuite/libmudflap.c/pass50-frag.c | 29 |
4 files changed, 81 insertions, 0 deletions
diff --git a/libmudflap/ChangeLog b/libmudflap/ChangeLog index 984e22bbe73..97ab17c72f4 100644 --- a/libmudflap/ChangeLog +++ b/libmudflap/ChangeLog @@ -1,3 +1,8 @@ +2004-10-02 Frank Ch. Eigler <fche@redhat.com> + + * testsuite/libmudflap.c/pass50-frag.c, fail33-frag.c, fail34-frag.c: + New tests for proper base/limit checking for aggregates. + 2004-09-15 Joseph S. Myers <jsm@polyomino.org.uk> * testsuite/libmudflap.c/pass35-frag.c: Update expected message. diff --git a/libmudflap/testsuite/libmudflap.c/fail33-frag.c b/libmudflap/testsuite/libmudflap.c/fail33-frag.c new file mode 100644 index 00000000000..5f33be7a852 --- /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; + 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 00000000000..f6572b019a4 --- /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/pass50-frag.c b/libmudflap/testsuite/libmudflap.c/pass50-frag.c new file mode 100644 index 00000000000..ac9ee090950 --- /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; +} |