diff options
author | Brian Smith <brian@briansmith.org> | 2015-03-17 08:27:05 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-04-13 23:29:05 +0300 |
commit | 1a9bc441270732fd89e2a2d268c122ade759d7f9 (patch) | |
tree | 8032f6132738e280f22c7444dabfef41f8b2f992 /crypto/internal.h | |
parent | 655764a22a9fdcb130d37744c8883776a32f08b5 (diff) |
Fix standalone Windows release-mode builds.
`cmake -GNinja .. -DCMAKE_BUILD_TYPE=Release` fails without this
patch, when building using MSVC 2013.
MSVC will detect (in release builds only, it seems) that functions that
call abort will never return, and then warn that any code after a call
to one of them is unreachable. Since we treat warnings as errors when
building, this breaks the build. While this is usually desirable, it
isn't desirable in this case.
Change-Id: Ie5f24b1beb60fd2b33582a2ceef4c378ad0678fb
Reviewed-on: https://boringssl-review.googlesource.com/3960
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/internal.h')
-rw-r--r-- | crypto/internal.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crypto/internal.h b/crypto/internal.h index 30e6e924..38f9820e 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -120,6 +120,26 @@ extern "C" { #endif +/* MSVC will sometimes correctly detect unreachable code and issue a warning, + * which breaks the build since we treat errors as warnings, in some rare cases + * where we want to allow the dead code to continue to exist. In these + * situations, annotate the function containing the unreachable code with + * OPENSSL_SUPPRESS_UNREACHABLE_CODE_WARNINGS after its parameters: + * + * void f() OPENSSL_SUPPRESS_UNREACHABLE_CODE_WARNINGS { + * ... + * } + * + * Note that MSVC's reachability analysis seems to operate on a whole-function + * basis, so the annotation must be placed on the entire function, not just a + * block within the function. */ +#if defined(_MSC_VER) +#define OPENSSL_SUPPRESS_UNREACHABLE_CODE_WARNINGS \ + __pragma(warning(suppress:4702)) +#else +#define OPENSSL_SUPPRESS_UNREACHABLE_CODE_WARNINGS +#endif + /* st_CRYPTO_EX_DATA_IMPL contains an ex_data implementation. See the comments * in ex_data.h for details of the behaviour of each of the functions. */ struct st_CRYPTO_EX_DATA_IMPL { |