Commit ee8f136a by Ilya Enkovich Committed by Ilya Enkovich

mpx-dg.exp (mpx_link_flags): New.

gcc/testsuites/

	* gcc/testsuite/lib/mpx-dg.exp (mpx_link_flags): New.
	(mpx_init): New.
	(mpx_finish): New.
	* gcc.target/i386/mpx/alloca-1-lbv.c: New.
	* gcc.target/i386/mpx/alloca-1-nov.c: New.
	* gcc.target/i386/mpx/alloca-1-ubv.c: New.
	* gcc.target/i386/mpx/arg-addr-1-lbv.c: New.
	* gcc.target/i386/mpx/arg-addr-1-nov.c: New.
	* gcc.target/i386/mpx/arg-addr-1-ubv.c: New.
	* gcc.target/i386/mpx/bitfields-1-lbv.c: New.
	* gcc.target/i386/mpx/bitfields-1-nov.c: New.
	* gcc.target/i386/mpx/bitfields-1-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-lbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-1-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-bounds-2.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-lbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-1-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-lbounds-2.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-1-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-chk-ptr-ubounds-2.c: New.
	* gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-1.c: New.
	* gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-lbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-2-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-copy-ptr-bounds-3.c: New.
	* gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-1.c: New.
	* gcc.target/i386/mpx/builtin-bnd-get-ptr-lbound-2.c: New.
	* gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-1.c: New.
	* gcc.target/i386/mpx/builtin-bnd-get-ptr-ubound-2.c: New.
	* gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-1.c: New.
	* gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-2-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-init-ptr-bounds-3.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-1.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-lbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-2-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-lbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-3-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-narrow-ptr-bounds-4.c: New.
	* gcc.target/i386/mpx/builtin-bnd-null-ptr-bounds-1-bbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-1.c: New.
	* gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-lbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-2-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-set-ptr-bounds-3.c: New.
	* gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-lbv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-nov.c: New.
	* gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-1-ubv.c: New.
	* gcc.target/i386/mpx/builtin-bnd-store-ptr-bounds-2.c: New.
	* gcc.target/i386/mpx/fastcall-1-lbv.c: New.
	* gcc.target/i386/mpx/fastcall-1-nov.c: New.
	* gcc.target/i386/mpx/fastcall-1-ubv.c: New.
	* gcc.target/i386/mpx/fastcall-2-lbv.c: New.
	* gcc.target/i386/mpx/fastcall-2-nov.c: New.
	* gcc.target/i386/mpx/fastcall-2-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-1-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-1-nov.c: New.
	* gcc.target/i386/mpx/field-addr-1-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-10-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-10-nov.c: New.
	* gcc.target/i386/mpx/field-addr-10-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-2-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-2-nov.c: New.
	* gcc.target/i386/mpx/field-addr-2-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-3-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-3-nov.c: New.
	* gcc.target/i386/mpx/field-addr-3-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-4-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-4-nov.c: New.
	* gcc.target/i386/mpx/field-addr-4-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-5-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-5-nov.c: New.
	* gcc.target/i386/mpx/field-addr-5-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-6-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-6-nov.c: New.
	* gcc.target/i386/mpx/field-addr-6-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-7-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-7-nov.c: New.
	* gcc.target/i386/mpx/field-addr-7-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-8-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-8-nov.c: New.
	* gcc.target/i386/mpx/field-addr-8-ubv.c: New.
	* gcc.target/i386/mpx/field-addr-9-lbv.c: New.
	* gcc.target/i386/mpx/field-addr-9-nov.c: New.
	* gcc.target/i386/mpx/field-addr-9-ubv.c: New.
	* gcc.target/i386/mpx/frame-address-1-nov.c: New.
	* gcc.target/i386/mpx/hard-reg-1-nov.c: New.
	* gcc.target/i386/mpx/if-stmt-1-lbv.c: New.
	* gcc.target/i386/mpx/if-stmt-1-nov.c: New.
	* gcc.target/i386/mpx/if-stmt-1-ubv.c: New.
	* gcc.target/i386/mpx/if-stmt-2-lbv.c: New.
	* gcc.target/i386/mpx/if-stmt-2-nov.c: New.
	* gcc.target/i386/mpx/if-stmt-2-ubv.c: New.
	* gcc.target/i386/mpx/label-address-1.c: New.
	* gcc.target/i386/mpx/legacy-1-nov.c: New.
	* gcc.target/i386/mpx/macro.c: New.
	* gcc.target/i386/mpx/mpx-check.h: New.
	* gcc.target/i386/mpx/mpx.exp: New.
	* gcc.target/i386/mpx/nested-function-1-lbv.c: New.
	* gcc.target/i386/mpx/nested-function-1-nov.c: New.
	* gcc.target/i386/mpx/nested-function-1-ubv.c: New.
	* gcc.target/i386/mpx/pointer-arg-1-lbv.c: New.
	* gcc.target/i386/mpx/pointer-arg-1-nov.c: New.
	* gcc.target/i386/mpx/pointer-arg-1-ubv.c: New.
	* gcc.target/i386/mpx/pointer-arg-2-lbv.c: New.
	* gcc.target/i386/mpx/pointer-arg-2-nov.c: New.
	* gcc.target/i386/mpx/pointer-arg-2-ubv.c: New.
	* gcc.target/i386/mpx/pointer-arg-3-lbv.c: New.
	* gcc.target/i386/mpx/pointer-arg-3-nov.c: New.
	* gcc.target/i386/mpx/pointer-arg-3-ubv.c: New.
	* gcc.target/i386/mpx/pointer-arg-4-lbv.c: New.
	* gcc.target/i386/mpx/pointer-arg-4-nov.c: New.
	* gcc.target/i386/mpx/pointer-arg-4-ubv.c: New.
	* gcc.target/i386/mpx/pointer-arg-5-lbv.c: New.
	* gcc.target/i386/mpx/pointer-arg-5-nov.c: New.
	* gcc.target/i386/mpx/pointer-arg-5-ubv.c: New.
	* gcc.target/i386/mpx/pointer-store-1-lbv.c: New.
	* gcc.target/i386/mpx/pointer-store-1-nov.c: New.
	* gcc.target/i386/mpx/pointer-store-1-ubv.c: New.
	* gcc.target/i386/mpx/reference-1-lbv.c: New.
	* gcc.target/i386/mpx/reference-1-nov.c: New.
	* gcc.target/i386/mpx/reference-1-ubv.c: New.
	* gcc.target/i386/mpx/reference-2-lbv.c: New.
	* gcc.target/i386/mpx/reference-2-nov.c: New.
	* gcc.target/i386/mpx/reference-2-ubv.c: New.
	* gcc.target/i386/mpx/reference-3-lbv.c: New.
	* gcc.target/i386/mpx/reference-3-nov.c: New.
	* gcc.target/i386/mpx/reference-3-ubv.c: New.
	* gcc.target/i386/mpx/reference-4-lbv.c: New.
	* gcc.target/i386/mpx/reference-4-nov.c: New.
	* gcc.target/i386/mpx/reference-4-ubv.c: New.
	* gcc.target/i386/mpx/return-pointer-1-lbv.c: New.
	* gcc.target/i386/mpx/return-pointer-1-nov.c: New.
	* gcc.target/i386/mpx/return-pointer-1-ubv.c: New.
	* gcc.target/i386/mpx/return-struct-1-lbv.c: New.
	* gcc.target/i386/mpx/return-struct-1-nov.c: New.
	* gcc.target/i386/mpx/return-struct-1-ubv.c: New.
	* gcc.target/i386/mpx/return-struct-2-lbv.c: New.
	* gcc.target/i386/mpx/return-struct-2-nov.c: New.
	* gcc.target/i386/mpx/return-struct-2-ubv.c: New.
	* gcc.target/i386/mpx/return-struct-3-lbv.c: New.
	* gcc.target/i386/mpx/return-struct-3-nov.c: New.
	* gcc.target/i386/mpx/return-struct-3-ubv.c: New.
	* gcc.target/i386/mpx/return-struct-4-lbv.c: New.
	* gcc.target/i386/mpx/return-struct-4-nov.c: New.
	* gcc.target/i386/mpx/return-struct-4-ubv.c: New.
	* gcc.target/i386/mpx/return-struct-5-lbv.c: New.
	* gcc.target/i386/mpx/return-struct-5-nov.c: New.
	* gcc.target/i386/mpx/return-struct-5-ubv.c: New.
	* gcc.target/i386/mpx/return-struct-6-lbv.c: New.
	* gcc.target/i386/mpx/return-struct-6-nov.c: New.
	* gcc.target/i386/mpx/return-struct-6-ubv.c: New.
	* gcc.target/i386/mpx/sincos-1-nov.c: New.
	* gcc.target/i386/mpx/static-array-1-lbv.c: New.
	* gcc.target/i386/mpx/static-array-1-nov.c: New.
	* gcc.target/i386/mpx/static-array-1-ubv.c: New.
	* gcc.target/i386/mpx/static-init-1-lbv.c: New.
	* gcc.target/i386/mpx/static-init-1-nov.c: New.
	* gcc.target/i386/mpx/static-init-1-ubv.c: New.
	* gcc.target/i386/mpx/static-init-2-lbv.c: New.
	* gcc.target/i386/mpx/static-init-2-nov.c: New.
	* gcc.target/i386/mpx/static-init-2-ubv.c: New.
	* gcc.target/i386/mpx/static-init-3-lbv.c: New.
	* gcc.target/i386/mpx/static-init-3-nov.c: New.
	* gcc.target/i386/mpx/static-init-3-ubv.c: New.
	* gcc.target/i386/mpx/static-init-4-lbv.c: New.
	* gcc.target/i386/mpx/static-init-4-nov.c: New.
	* gcc.target/i386/mpx/static-init-4-ubv.c: New.
	* gcc.target/i386/mpx/static-init-5-lbv.c: New.
	* gcc.target/i386/mpx/static-init-5-nov.c: New.
	* gcc.target/i386/mpx/static-init-5-ubv.c: New.
	* gcc.target/i386/mpx/static-init-6-lbv.c: New.
	* gcc.target/i386/mpx/static-init-6-nov.c: New.
	* gcc.target/i386/mpx/static-init-6-ubv.c: New.
	* gcc.target/i386/mpx/static-string-1-lbv.c: New.
	* gcc.target/i386/mpx/static-string-1-nov.c: New.
	* gcc.target/i386/mpx/static-string-1-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-1-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-1-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-1-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-10-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-10-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-10-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-2-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-2-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-2-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-3-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-3-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-3-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-4-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-4-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-4-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-5-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-5-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-5-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-6-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-6-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-6-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-7-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-7-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-7-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-8-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-8-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-8-ubv.c: New.
	* gcc.target/i386/mpx/struct-arg-9-lbv.c: New.
	* gcc.target/i386/mpx/struct-arg-9-nov.c: New.
	* gcc.target/i386/mpx/struct-arg-9-ubv.c: New.
	* gcc.target/i386/mpx/struct-copy-1-lbv.c: New.
	* gcc.target/i386/mpx/struct-copy-1-nov.c: New.
	* gcc.target/i386/mpx/struct-copy-1-ubv.c: New.
	* gcc.target/i386/mpx/struct-copy-2-lbv.c: New.
	* gcc.target/i386/mpx/struct-copy-2-nov.c: New.
	* gcc.target/i386/mpx/struct-copy-2-ubv.c: New.
	* gcc.target/i386/mpx/thread-local-var-1-lbv.c: New.
	* gcc.target/i386/mpx/thread-local-var-1-nov.c: New.
	* gcc.target/i386/mpx/thread-local-var-1-ubv.c: New.
	* gcc.target/i386/mpx/union-arg-1-lbv.c: New.
	* gcc.target/i386/mpx/union-arg-1-nov.c: New.
	* gcc.target/i386/mpx/union-arg-1-ubv.c: New.
	* gcc.target/i386/mpx/va-arg-pack-1-lbv.c: New.
	* gcc.target/i386/mpx/va-arg-pack-1-nov.c: New.
	* gcc.target/i386/mpx/va-arg-pack-1-ubv.c: New.
	* gcc.target/i386/mpx/va-arg-pack-2-lbv.c: New.
	* gcc.target/i386/mpx/va-arg-pack-2-nov.c: New.
	* gcc.target/i386/mpx/va-arg-pack-2-ubv.c: New.
	* gcc.target/i386/mpx/vararg-1-lbv.c: New.
	* gcc.target/i386/mpx/vararg-1-nov.c: New.
	* gcc.target/i386/mpx/vararg-1-ubv.c: New.
	* gcc.target/i386/mpx/vararg-2-lbv.c: New.
	* gcc.target/i386/mpx/vararg-2-nov.c: New.
	* gcc.target/i386/mpx/vararg-2-ubv.c: New.
	* gcc.target/i386/mpx/vararg-3-lbv.c: New.
	* gcc.target/i386/mpx/vararg-3-nov.c: New.
	* gcc.target/i386/mpx/vararg-3-ubv.c: New.
	* gcc.target/i386/mpx/vararg-4-lbv.c: New.
	* gcc.target/i386/mpx/vararg-4-nov.c: New.
	* gcc.target/i386/mpx/vararg-4-ubv.c: New.
	* gcc.target/i386/mpx/vararg-5-lbv.c: New.
	* gcc.target/i386/mpx/vararg-5-nov.c: New.
	* gcc.target/i386/mpx/vararg-5-ubv.c: New.
	* gcc.target/i386/mpx/vararg-6-lbv.c: New.
	* gcc.target/i386/mpx/vararg-6-nov.c: New.
	* gcc.target/i386/mpx/vararg-6-ubv.c: New.
	* gcc.target/i386/mpx/vararg-7-lbv.c: New.
	* gcc.target/i386/mpx/vararg-7-nov.c: New.
	* gcc.target/i386/mpx/vararg-7-ubv.c: New.
	* gcc.target/i386/mpx/vararg-8-lbv.c: New.
	* gcc.target/i386/mpx/vararg-8-nov.c: New.
	* gcc.target/i386/mpx/vararg-8-ubv.c: New.
	* gcc.target/i386/mpx/vla-1-lbv.c: New.
	* gcc.target/i386/mpx/vla-1-nov.c: New.
	* gcc.target/i386/mpx/vla-1-ubv.c: New.
	* gcc.target/i386/mpx/vla-2-lbv.c: New.
	* gcc.target/i386/mpx/vla-2-nov.c: New.
	* gcc.target/i386/mpx/vla-2-ubv.c: New.

From-SVN: r221312
parent 5373cd33
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
int *buf = (int *)alloca (100 * sizeof(int));
rd (buf, -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
int *buf = (int *)alloca (100 * sizeof(int));
rd (buf, 0);
rd (buf, 99);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
int *buf = (int *)alloca (100 * sizeof(int));
rd (buf, 100);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int foo (int i, int j)
{
return rd(&i, j);
}
int mpx_test (int argc, const char **argv)
{
foo (1, -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int foo (int i, int j)
{
return rd(&i, j);
}
int mpx_test (int argc, const char **argv)
{
foo (1, 0);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int foo (int i, int j)
{
return rd(&i, j);
}
int mpx_test (int argc, const char **argv)
{
foo (1, 1);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct s {
int a;
int b : 10;
int c : 1;
int e : 10;
} s;
#define HH (unsigned char)1
int foo (struct s *p)
{
int val = p->b;
printf ("%d\n", val);
return val == HH;
}
int mpx_test (int argc, const char **argv)
{
struct s buf[100];
foo (buf - 1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
struct s {
int a;
int b : 10;
int c : 1;
int e : 10;
} s;
#define HH (unsigned char)1
int foo (struct s *p)
{
int val = p->b;
printf ("%d\n", val);
return val == HH;
}
int mpx_test (int argc, const char **argv)
{
struct s buf[100];
foo (buf);
foo (buf + 99);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct s {
int a;
int b : 10;
int c : 1;
int e : 10;
} s;
#define HH (unsigned char)1
int foo (struct s *p)
{
int val = p->b;
printf ("%d\n", val);
return val == HH;
}
int mpx_test (int argc, const char **argv)
{
struct s buf[100];
foo (buf + 100);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_bounds (buf - 1, sizeof (int));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_bounds (buf, sizeof (int) * 100);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_bounds (buf + 100, sizeof (int));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_bounds (buf - 1, sizeof (int));
__bnd_chk_ptr_bounds (buf + 100, sizeof (int));
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_lbounds (buf - 1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_lbounds (buf);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_lbounds (buf - 1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_ubounds (buf + 99);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_ubounds (buf + 100);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
__bnd_chk_ptr_ubounds (buf + 100);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 10 == __bnd_copy_ptr_bounds (buf + 10, buf));
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
int *p1 = __bnd_copy_ptr_bounds (buf, p);
p1[9] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
int *p1 = __bnd_copy_ptr_bounds (buf, p);
p1[10] = argc;
p1[19] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
int *p1 = __bnd_copy_ptr_bounds (buf, p);
p1[20] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 10 == __bnd_copy_ptr_bounds (buf + 10, buf));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
char buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf == __bnd_get_ptr_lbound (buf));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
char buf[100];
int mpx_test (int argc, const char **argv)
{
assert ((void *)0 == __bnd_get_ptr_lbound (buf));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
char buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 99 == __bnd_get_ptr_ubound (buf));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
char buf[100];
int mpx_test (int argc, const char **argv)
{
assert ((void *)-1 == __bnd_get_ptr_ubound (buf));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 10 == __bnd_init_ptr_bounds (buf + 10));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p = __bnd_init_ptr_bounds (p);
p[-1] = argc;
p[10] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 10 == __bnd_init_ptr_bounds (buf + 10));
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 10 == __bnd_narrow_ptr_bounds (buf + 10, buf, 4));
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_narrow_ptr_bounds (buf - 10, buf, sizeof (int) * 20);
p[9] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_narrow_ptr_bounds (buf - 10, buf, sizeof (int) * 20);
p[10] = argc;
p[19] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_narrow_ptr_bounds (buf - 10, buf, sizeof (int) * 20);
p[20] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_narrow_ptr_bounds (buf + 10, buf, sizeof (int) * 100);
p[-1] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_narrow_ptr_bounds (buf + 10, buf, sizeof (int) * 100);
p[0] = argc;
p[89] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_narrow_ptr_bounds (buf + 10, buf, sizeof (int) * 100);
p[90] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf - 10 == __bnd_narrow_ptr_bounds (buf - 10, buf, 4));
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_null_ptr_bounds (buf + 10);
p[0] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 10 == __bnd_set_ptr_bounds (buf + 10, 4));
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p[-1] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p[0] = argc;
p[9] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p[10] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int mpx_test (int argc, const char **argv)
{
assert (buf + 10 == __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10));
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int *p;
int mpx_test (int argc, const char **argv)
{
int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p = buf;
__bnd_store_ptr_bounds ((void **)&p, p1 - 10);
p[9] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
int *p;
int mpx_test (int argc, const char **argv)
{
int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p = buf;
__bnd_store_ptr_bounds ((void **)&p, p1 - 10);
p[10] = argc;
p[19] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int buf[100];
int *p;
int mpx_test (int argc, const char **argv)
{
int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p = buf;
__bnd_store_ptr_bounds ((void **)&p, p1 - 10);
p[20] = argc;
return 0;
}
/* { dg-do run } */
/* { dg-options "-fno-check-pointer-bounds" } */
#include "mpx-check.h"
int buf[100];
int *p;
int mpx_test (int argc, const char **argv)
{
int *p1 = __bnd_set_ptr_bounds (buf + 10, sizeof (int) * 10);
p = buf;
__bnd_store_ptr_bounds ((void **)&p, p1);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-require-effective-target ia32 } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
__attribute__((fastcall)) int rd (int *p1, int *p2, int i)
{
int res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int buf1[10];
int mpx_test (int argc, const char **argv)
{
rd (buf1, buf, -1);
return 0;
}
/* { dg-do run } */
/* { dg-require-effective-target ia32 } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
__attribute__((fastcall)) int rd (int *p1, int *p2, int i)
{
int res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int buf1[10];
int mpx_test (int argc, const char **argv)
{
rd (buf1, buf, 0);
rd (buf1, buf, 9);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-require-effective-target ia32 } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
__attribute__((fastcall)) int rd (int *p1, int *p2, int i)
{
int res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int buf1[10];
int mpx_test (int argc, const char **argv)
{
rd (buf1, buf, 10);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-require-effective-target ia32 } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
__attribute__((fastcall)) int rd (int *p1, int *p2, int i)
{
int res = p2[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int buf1[10];
int mpx_test (int argc, const char **argv)
{
rd (buf, buf1, -1);
return 0;
}
/* { dg-do run } */
/* { dg-require-effective-target ia32 } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
__attribute__((fastcall)) int rd (int *p1, int *p2, int i)
{
int res = p2[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int buf1[10];
int mpx_test (int argc, const char **argv)
{
rd (buf, buf1, 0);
rd (buf, buf1, 9);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-require-effective-target ia32 } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
__attribute__((fastcall)) int rd (int *p1, int *p2, int i)
{
int res = p2[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int buf1[10];
int mpx_test (int argc, const char **argv)
{
rd (buf, buf1, 10);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *i, int k)
{
printf ("%d\n", i[k]);
return i[k];
}
int mpx_test (int argc, const char **argv)
{
struct S s;
foo(&s.a, -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *i, int k)
{
printf ("%d\n", i[k]);
return i[k];
}
int mpx_test (int argc, const char **argv)
{
struct S s;
foo(&s.a, 0);
foo(&s.a, 101);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *i, int k)
{
printf ("%d\n", i[k]);
return i[k];
}
int mpx_test (int argc, const char **argv)
{
struct S s;
foo(&s.a, 102);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int arr[100];
} S;
struct S sa[10];
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
rd (&sa[argc].arr[0], -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#include "mpx-check.h"
struct S {
int arr[100];
} S;
struct S sa[10];
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
rd (&sa[argc].arr[0], 0);
rd (&sa[argc].arr[0], 99);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int arr[100];
} S;
struct S sa[10];
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
rd (&sa[argc].arr[0], 100);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-first-field-has-own-bounds" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *i, int k)
{
printf ("%d\n", i[k]);
return i[k];
}
int mpx_test (int argc, const char **argv)
{
struct S s;
foo(&s.a, -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-first-field-has-own-bounds" } */
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *i, int k)
{
printf ("%d\n", i[k]);
return i[k];
}
int mpx_test (int argc, const char **argv)
{
struct S s;
foo(&s.a, 0);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-first-field-has-own-bounds" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *i, int k)
{
printf ("%d\n", i[k]);
return i[k];
}
int mpx_test (int argc, const char **argv)
{
struct S s;
foo(&s.a, 1);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S s;
int mpx_test (int argc, const char **argv)
{
foo (&s.b[0], -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S s;
int mpx_test (int argc, const char **argv)
{
foo (&s.b[0], 0);
foo (&s.b[0], 99);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S s;
int mpx_test (int argc, const char **argv)
{
foo (&s.b[0], 100);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
int mpx_test (int argc, const char **argv)
{
foo (&s1.a[0].a, -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
int mpx_test (int argc, const char **argv)
{
foo (&s1.a[9].c, 0);
foo (&s1.a[0].a, 0);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
int mpx_test (int argc, const char **argv)
{
foo (&s1.a[9].c, 1);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
int mpx_test (int argc, const char **argv)
{
foo (&s1.b.b[0], -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
int mpx_test (int argc, const char **argv)
{
foo (&s1.b.b[0], 0);
foo (&s1.b.b[0], 99);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
int mpx_test (int argc, const char **argv)
{
foo (&s1.b.b[0], 100);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
struct S1 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[0].a), -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
struct S1 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[0].a), 0);
foo (&(s2->a[9].a), 101);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a;
int b[100];
int c;
} S;
struct S1 {
int x;
struct S a[10];
struct S b;
} S1;
int foo (int *p, int i)
{
printf ("%d\n", p[i]);
return p[i];
}
struct S1 s1;
struct S1 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[9].a), 102);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[-1].a), 0);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
struct S {
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[0].a), 0);
foo (&(s2->a[9].c), 0);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[10].a), 0);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s1.a[argc].b[-1].a[0]), 9);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#include "mpx-check.h"
struct S {
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s1.a[argc].b[0].a[0]), 0);
foo (&(s1.a[argc].b[0].a[0]), 9);
foo (&(s1.a[argc].b[9].a[0]), 0);
foo (&(s1.a[argc].b[9].a[0]), 9);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s1.a[argc].b[10].a[0]), 9);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int first;
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[argc].b[5].a[0]), -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#include "mpx-check.h"
struct S {
int first;
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[argc].b[5].a[0]), 0);
foo (&(s2->a[argc].b[5].a[0]), 9);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
/* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
#define SHOULDFAIL
#include "mpx-check.h"
struct S {
int first;
int a[10];
int b;
} S;
struct S1 {
int a;
struct S b[10];
int c;
} S1;
struct S2 {
int x;
struct S1 a[10];
struct S1 b;
} S2;
int foo (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
struct S2 s1;
struct S2 *s2 = &s1;
int mpx_test (int argc, const char **argv)
{
foo (&(s2->a[argc].b[5].a[0]), 10);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int mpx_test (int argc, const char **argv)
{
void **fa = (void **)__builtin_frame_address (0);
printf ("%p\n", *fa);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
register int *frame __asm__("rsp");
rd (frame, 1);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p1, int *p2, int i)
{
int res;
if (p1 < p2)
p1 = p2;
res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 1, 40);
rd (buf, p, -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int rd (int *p1, int *p2, int i)
{
int res;
if (p1 < p2)
p1 = p2;
res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 1, 40);
rd (buf, p, 0);
rd (buf, p, 9);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p1, int *p2, int i)
{
int res;
if (p1 < p2)
p1 = p2;
res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 1, 40);
rd (buf, p, 10);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p1, int *p2, int i)
{
int res;
if (p1 > p2)
p1 = p2;
res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 1, 40);
rd (buf, p, -1);
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int rd (int *p1, int *p2, int i)
{
int res;
if (p1 > p2)
p1 = p2;
res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 1, 40);
rd (buf, p, 0);
rd (buf, p, 99);
return 0;
}
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int rd (int *p1, int *p2, int i)
{
int res;
if (p1 > p2)
p1 = p2;
res = p1[i];
printf ("%d\n", res);
return res;
}
int buf[100];
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 1, 40);
rd (buf, p, 100);
return 0;
}
/* { dg-do compile } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
void *p;
int mpx_test (int argc, const char **argv)
{
p = &&label;
label:
return 0;
}
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
int buf[100];
__attribute__((bnd_legacy))
int rd (int *p, int i)
{
int res = p[i];
printf ("%d\n", res);
return res;
}
int mpx_test (int argc, const char **argv)
{
int *p = __bnd_set_ptr_bounds (buf + 1, 10);
rd (p, -1);
rd (p, 10);
return 0;
}
/* { dg-do compile } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#include "mpx-check.h"
#ifndef __MPX__
#error -mmpx is required
#endif
#ifndef __CHKP__
#error -fcheck-pointer-bounds is required
#endif
int mpx_test (int argc, const char **argv)
{
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "cpuid.h"
static int
__attribute__ ((noinline))
mpx_test (int, const char **);
#ifdef SHOULDFAIL
#define NORUNRES 1
#else
#define NORUNRES 0
#endif
#define DEBUG
int
main (int argc, const char **argv)
{
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid_max (0, NULL) < 7)
return 0;
__cpuid_count (7, 0, eax, ebx, ecx, edx);
/* Run MPX test only if host has MPX support. */
if (ebx & bit_MPX)
mpx_test (argc, argv);
else
{
#ifdef DEBUG
printf ("SKIPPED\n");
#endif
return NORUNRES;
}
return 0;
}
# Copyright (C) 2014 Free Software Foundation, Inc.
#
# This file is part of GCC.
#
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GCC 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# Exit immediately if this isn't a x86 target.
if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then {
return
}
# Load support procs.
load_lib gcc-dg.exp
load_lib mpx-dg.exp
# Initialize.
dg-init
mpx_init
if [check_effective_target_mpx] {
# Run all tests.
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c*]] "" ""
}
# All done.
mpx_finish
dg-finish
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
#define SHOULDFAIL
#include "mpx-check.h"
int mpx_test (int argc, const char **argv)
{
int a[100];
void rd (int i)
{
printf ("%d\n", a[i]);
}
rd (-1);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment