From 04bfa1e4691afb9eb0edcd9e80ec1e542628c7d4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 8 Dec 2016 06:32:24 -0800 Subject: [PATCH] Enable -fsanitize-address-use-after-scope only if -fsanitize=address is enabled 2016-12-08 Dmitry Vyukov * opts.c (finish_options): Enable -fsanitize-address-use-after-scope only if -fsanitize=address is enabled (not -fsanitize=kernel-address). * doc/invoke.texi (-fsanitize=kernel-address): Don't say that it enables -fsanitize-address-use-after-scope. From-SVN: r243441 --- gcc/ChangeLog | 8 ++++++++ gcc/doc/invoke.texi | 1 - gcc/opts.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 91a1ed3562d..37666662a10 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-12-08 Dmitry Vyukov + + * opts.c (finish_options): Enable + -fsanitize-address-use-after-scope only if -fsanitize=address is enabled + (not -fsanitize=kernel-address). + * doc/invoke.texi (-fsanitize=kernel-address): + Don't say that it enables -fsanitize-address-use-after-scope. + 2016-12-08 Bin Cheng PR middle-end/78684 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 5622c0f107e..02a34fb724d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -10640,7 +10640,6 @@ The option can't be combined with @option{-fsanitize=thread}. @item -fsanitize=kernel-address @opindex fsanitize=kernel-address Enable AddressSanitizer for Linux kernel. -The option enables @option{-fsanitize-address-use-after-scope}. See @uref{https://github.com/google/kasan/wiki} for more details. @item -fsanitize=thread diff --git a/gcc/opts.c b/gcc/opts.c index c61c3677a66..890da03e6a1 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -990,7 +990,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, /* Enable -fsanitize-address-use-after-scope if address sanitizer is enabled. */ - if (opts->x_flag_sanitize + if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS) && !opts_set->x_flag_sanitize_address_use_after_scope) opts->x_flag_sanitize_address_use_after_scope = true; -- 2.30.2