aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-11-23 20:51:27 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2016-11-23 20:51:27 +0100
commitc944c6a2b209843fc94844838ed8223d669ab401 (patch)
tree3825ef1789a5f68b24611672321b90423314837a /gcc
parent871a2c6c8bb82158a9ab4a54a3e8114a098641ea (diff)
downloadgcc-c944c6a2b209843fc94844838ed8223d669ab401.zip
gcc-c944c6a2b209843fc94844838ed8223d669ab401.tar.gz
gcc-c944c6a2b209843fc94844838ed8223d669ab401.tar.bz2
re PR sanitizer/69278 (Confusion option handling for -sanitize-recovery=alll)
PR sanitizer/69278 * opts.c (parse_sanitizer_options): For -fsanitize=undefined, restore enabling also SANITIZE_UNREACHABLE and SANITIZE_RETURN. * g++.dg/ubsan/return-7.C: New test. * c-c++-common/ubsan/unreachable-4.c: New test. From-SVN: r242795
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/opts.c3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/unreachable-4.c10
-rw-r--r--gcc/testsuite/g++.dg/ubsan/return-7.C27
5 files changed, 49 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c610804..276d8b8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2016-11-23 Jakub Jelinek <jakub@redhat.com>
+ PR sanitizer/69278
+ * opts.c (parse_sanitizer_options): For -fsanitize=undefined,
+ restore enabling also SANITIZE_UNREACHABLE and SANITIZE_RETURN.
+
+2016-11-23 Jakub Jelinek <jakub@redhat.com>
+
PR middle-end/69183
* omp-low.c (build_outer_var_ref): Change lastprivate argument
to code, pass it recursively, adjust uses. For OMP_CLAUSE_PRIVATE
diff --git a/gcc/opts.c b/gcc/opts.c
index cb20154..c61c367 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1558,7 +1558,8 @@ parse_sanitizer_options (const char *p, location_t loc, int scode,
/* Do not enable -fsanitize-recover=unreachable and
-fsanitize-recover=return if -fsanitize-recover=undefined
is selected. */
- if (sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
+ if (code == OPT_fsanitize_recover_
+ && sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
flags |= (SANITIZE_UNDEFINED
& ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN));
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 317b4d1..b8cb594 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2016-11-23 Jakub Jelinek <jakub@redhat.com>
+ PR sanitizer/69278
+ * g++.dg/ubsan/return-7.C: New test.
+ * c-c++-common/ubsan/unreachable-4.c: New test.
+
PR tree-optimization/78482
* gcc.dg/torture/pr78482.c (c, d): Use signed char instead of char.
(bar): New function.
diff --git a/gcc/testsuite/c-c++-common/ubsan/unreachable-4.c b/gcc/testsuite/c-c++-common/ubsan/unreachable-4.c
new file mode 100644
index 0000000..71b56e3f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/unreachable-4.c
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined" } */
+/* { dg-shouldfail "ubsan" } */
+
+int
+main (void)
+{
+ __builtin_unreachable ();
+}
+ /* { dg-output "execution reached a __builtin_unreachable\\(\\) call" } */
diff --git a/gcc/testsuite/g++.dg/ubsan/return-7.C b/gcc/testsuite/g++.dg/ubsan/return-7.C
new file mode 100644
index 0000000..316cb4b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ubsan/return-7.C
@@ -0,0 +1,27 @@
+// { dg-do run }
+// { dg-options "-fsanitize=undefined" }
+// { dg-shouldfail "ubsan" }
+
+struct S { S (); ~S (); };
+
+S::S () {}
+S::~S () {}
+
+int
+foo (int x)
+{
+ S a;
+ {
+ S b;
+ if (x)
+ return 1;
+ }
+}
+
+int
+main ()
+{
+ foo (0);
+}
+
+// { dg-output "execution reached the end of a value-returning function without returning a value" }