diff options
author | Marek Polacek <polacek@redhat.com> | 2013-11-29 21:29:48 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2013-11-29 21:29:48 +0000 |
commit | f8ef336f0b6c726607bfda2795f362093cf7a2df (patch) | |
tree | e70bc6144ae7f2ffac9cf630265312a92d4b018d /gcc | |
parent | 340baef702ea62dfcdc8003ff9c4f4c2bd8322fb (diff) | |
download | gcc-f8ef336f0b6c726607bfda2795f362093cf7a2df.zip gcc-f8ef336f0b6c726607bfda2795f362093cf7a2df.tar.gz gcc-f8ef336f0b6c726607bfda2795f362093cf7a2df.tar.bz2 |
re PR sanitizer/59331 (ubsan gives extra warnings with vla.)
PR sanitizer/59331
cp/
* decl.c (compute_array_index_type): Don't build COMPOUND_EXPR for
instrumentation.
testsuite/
* g++.dg/ubsan/pr59331.C: New test.
* g++.dg/ubsan/cxx1y-vla.C: Enable -Wall -Wno-unused-variable.
Disable the -w option.
* c-c++-common/ubsan/vla-1.c: Likewise.
* c-c++-common/ubsan/vla-2.c: Likewise.
* c-c++-common/ubsan/vla-3.c: Don't use the -w option.
From-SVN: r205544
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/vla-1.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/vla-2.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/vla-3.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ubsan/pr59331.C | 8 |
8 files changed, 29 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1809afd..e2fc2a2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-11-29 Marek Polacek <polacek@redhat.com> + + PR sanitizer/59331 + * decl.c (compute_array_index_type): Don't build COMPOUND_EXPR for + instrumentation. + 2013-11-28 Jakub Jelinek <jakub@redhat.com> PR c++/59297 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9508131..820d9c0 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8434,8 +8434,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) LE_EXPR rather than LT_EXPR. */ tree t = fold_build2 (PLUS_EXPR, TREE_TYPE (itype), itype, build_one_cst (TREE_TYPE (itype))); - t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), - ubsan_instrument_vla (input_location, t), t); + t = ubsan_instrument_vla (input_location, t); finish_expr_stmt (t); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f3f6102..bad1f92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2013-11-29 Marek Polacek <polacek@redhat.com> + + PR sanitizer/59331 + * g++.dg/ubsan/pr59331.C: New test. + * g++.dg/ubsan/cxx1y-vla.C: Enable -Wall -Wno-unused-variable. + Disable the -w option. + * c-c++-common/ubsan/vla-1.c: Likewise. + * c-c++-common/ubsan/vla-2.c: Likewise. + * c-c++-common/ubsan/vla-3.c: Don't use the -w option. + 2013-11-29 Joseph Myers <joseph@codesourcery.com> PR c/42262 diff --git a/gcc/testsuite/c-c++-common/ubsan/vla-1.c b/gcc/testsuite/c-c++-common/ubsan/vla-1.c index 6c1d81e..3e47bd3 100644 --- a/gcc/testsuite/c-c++-common/ubsan/vla-1.c +++ b/gcc/testsuite/c-c++-common/ubsan/vla-1.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-fsanitize=vla-bound -w" } */ +/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable" } */ static int bar (void) diff --git a/gcc/testsuite/c-c++-common/ubsan/vla-2.c b/gcc/testsuite/c-c++-common/ubsan/vla-2.c index 2fbeb71..c62ced9 100644 --- a/gcc/testsuite/c-c++-common/ubsan/vla-2.c +++ b/gcc/testsuite/c-c++-common/ubsan/vla-2.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-fsanitize=vla-bound -w" } */ +/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable" } */ int main (void) diff --git a/gcc/testsuite/c-c++-common/ubsan/vla-3.c b/gcc/testsuite/c-c++-common/ubsan/vla-3.c index 20dd38b..5e10af0 100644 --- a/gcc/testsuite/c-c++-common/ubsan/vla-3.c +++ b/gcc/testsuite/c-c++-common/ubsan/vla-3.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-fsanitize=vla-bound -w" } */ +/* { dg-options "-fsanitize=vla-bound" } */ /* Don't instrument the arrays here. */ int diff --git a/gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C b/gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C index 350db3f..7023c70 100644 --- a/gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C +++ b/gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-fsanitize=vla-bound -w -std=c++1y" } */ +/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable -std=c++1y" } */ /* { dg-shouldfail "ubsan" } */ int diff --git a/gcc/testsuite/g++.dg/ubsan/pr59331.C b/gcc/testsuite/g++.dg/ubsan/pr59331.C new file mode 100644 index 0000000..1bb3666 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr59331.C @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable" } */ + +void foo(int i) +{ + /* Don't warn here with "value computed is not used". */ + char a[i]; +} |