From 913f32a121d0c3801de4b226e2cc24c39b84f84d Mon Sep 17 00:00:00 2001 From: Marat Zakirov Date: Mon, 13 Oct 2014 10:44:45 +0000 Subject: [PATCH] asan.c (instrument_derefs): BIT_FIELD_REF added. gcc/ChangeLog: 2014-09-19 Marat Zakirov * asan.c (instrument_derefs): BIT_FIELD_REF added. gcc/testsuite/ChangeLog: 2014-09-19 Marat Zakirov * c-c++-common/asan/bitfield-5.c: New test. From-SVN: r216144 --- gcc/ChangeLog | 4 ++++ gcc/asan.c | 1 + gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/asan/bitfield-5.c | 24 ++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/asan/bitfield-5.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a8359339684..667da04f2bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-10-13 Marat Zakirov + + * asan.c (instrument_derefs): BIT_FIELD_REF added. + 2014-10-13 Richard Biener PR tree-optimization/63419 diff --git a/gcc/asan.c b/gcc/asan.c index ba933c0a5e8..2a61a8243d3 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1711,6 +1711,7 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, case INDIRECT_REF: case MEM_REF: case VAR_DECL: + case BIT_FIELD_REF: break; /* FALLTHRU */ default: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ab2f218049..2134ada323d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-09-19 Marat Zakirov + + * c-c++-common/asan/bitfield-5.c: New test. + 2014-10-13 Richard Biener PR tree-optimization/63419 diff --git a/gcc/testsuite/c-c++-common/asan/bitfield-5.c b/gcc/testsuite/c-c++-common/asan/bitfield-5.c new file mode 100644 index 00000000000..eb5e9e9fe07 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/bitfield-5.c @@ -0,0 +1,24 @@ +/* Check BIT_FIELD_REF. */ + +/* { dg-do run } */ +/* { dg-shouldfail "asan" } */ + +struct A +{ + int y : 20; + int x : 13; +}; + +int __attribute__ ((noinline, noclone)) +f (void *p) { + return ((struct A *)p)->x != 0; +} + +int +main () +{ + int a = 0; + return f (&a); +} + +/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */ -- 2.30.2