From: Maxim Ostapenko Date: Thu, 19 May 2016 12:05:59 +0000 (+0000) Subject: re PR sanitizer/64354 (no preprocessor symbol __SANITIZE_THREAD__) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f3510625cf2035e6876246a9689db10163e96830;p=gcc.git re PR sanitizer/64354 (no preprocessor symbol __SANITIZE_THREAD__) 2016-05-19 Maxim Ostapenko PR sanitizer/64354 * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new builtin __SANITIZE_THREAD__ macros for fsanitize=thread switch. * doc/cpp.texi: Document new macros. * c-c++-common/tsan/sanitize-thread-macro.c: New test. From-SVN: r236457 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b39357a002c..e7d7ab8469a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-05-19 Maxim Ostapenko + + PR sanitizer/64354 + * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new + builtin __SANITIZE_THREAD__ macros for fsanitize=thread switch. + * doc/cpp.texi: Document new macros. + 2016-05-19 Bin Cheng PR tree-optimization/69848 diff --git a/gcc/cppbuiltin.c b/gcc/cppbuiltin.c index 6d494add73b..69ccdb91846 100644 --- a/gcc/cppbuiltin.c +++ b/gcc/cppbuiltin.c @@ -92,6 +92,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile) if (flag_sanitize & SANITIZE_ADDRESS) cpp_define (pfile, "__SANITIZE_ADDRESS__"); + if (flag_sanitize & SANITIZE_THREAD) + cpp_define (pfile, "__SANITIZE_THREAD__"); + if (optimize_size) cpp_define (pfile, "__OPTIMIZE_SIZE__"); if (optimize) diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 9f914b2759d..44f59bdfb47 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -2362,6 +2362,9 @@ in use. This macro is defined, with value 1, when @option{-fsanitize=address} or @option{-fsanitize=kernel-address} are in use. +@item __SANITIZE_THREAD__ +This macro is defined, with value 1, when @option{-fsanitize=thread} is in use. + @item __TIMESTAMP__ This macro expands to a string constant that describes the date and time of the last modification of the current source file. The string constant diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d14ebefc563..4f20c2cd63e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-19 Maxim Ostapenko + + PR sanitizer/64354 + * c-c++-common/tsan/sanitize-thread-macro.c: New test. + 2016-05-19 Richard Biener PR tree-optimization/70729 diff --git a/gcc/testsuite/c-c++-common/tsan/sanitize-thread-macro.c b/gcc/testsuite/c-c++-common/tsan/sanitize-thread-macro.c new file mode 100644 index 00000000000..2b8a840687c --- /dev/null +++ b/gcc/testsuite/c-c++-common/tsan/sanitize-thread-macro.c @@ -0,0 +1,12 @@ +/* Check that -fsanitize=thread options defines __SANITIZE_THREAD__ macros. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +int +main () +{ +#ifndef __SANITIZE_THREAD__ + bad construction +#endif + return 0; +}