]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR sanitizer/59331 (ubsan gives extra warnings with vla.)
authorMarek Polacek <polacek@redhat.com>
Fri, 29 Nov 2013 21:29:48 +0000 (21:29 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 29 Nov 2013 21:29:48 +0000 (21:29 +0000)
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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/vla-1.c
gcc/testsuite/c-c++-common/ubsan/vla-2.c
gcc/testsuite/c-c++-common/ubsan/vla-3.c
gcc/testsuite/g++.dg/ubsan/cxx1y-vla.C
gcc/testsuite/g++.dg/ubsan/pr59331.C [new file with mode: 0644]

index 1809afde902a1f0f5d08fb7eeda91f34d13cf21a..e2fc2a2d125b987b9933c0ea072c8b8023a95f15 100644 (file)
@@ -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
index 9508131388f188e9b83ba087642819533d7d2075..820d9c08f7b5720bd3ba0a5ebdca699e883c0301 100644 (file)
@@ -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);
            }
        }
index f3f610276331468cab74f12e97980abbdb7bef40..bad1f9273812f62fecf481e4461629dbf728de1d 100644 (file)
@@ -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
index 6c1d81e9d22022041afe1099fcd6880e28f73ebd..3e47bd39275b549eff038984f0c7a3b9417f20ee 100644 (file)
@@ -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)
index 2fbeb7113b8ff22f876eb68d1a6cb0d657851d5c..c62ced91348d940956b1cd3642d900496000192a 100644 (file)
@@ -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)
index 20dd38b79a7701d918051308656ffc0782d6f54e..5e10af0b593ac64e614278427e0a72c02f147adb 100644 (file)
@@ -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
index 350db3f34731f0679f7fa57108305c0f1db00955..7023c70cea0dfa51c484b3260fbef5dc3569ee47 100644 (file)
@@ -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 (file)
index 0000000..1bb3666
--- /dev/null
@@ -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];
+}