-
Notifications
You must be signed in to change notification settings - Fork 455
Set Certain Warnings as Errors Unconditionally #890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vector-of-bool
merged 20 commits into
mongodb:master
from
vector-of-bool:error-warnings-1
Dec 3, 2021
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
020f0f6
warn-as-error implicit functions
vector-of-bool 106a3d8
Some implicit fn decls
vector-of-bool c2f5ead
More warnings-as-errors
vector-of-bool b652301
MSVC fixes
vector-of-bool 34ddd13
More warnings, and fixes for C-only warnings
vector-of-bool b42e604
return-type now always on
vector-of-bool 5c1f027
Older-fashioned genex for CMake compatibility
vector-of-bool 26deb3f
Conditional COMPILE_LANGUAGE usage
vector-of-bool 354abb8
Merge branch 'master' into error-warnings-1
vector-of-bool 032fd16
Merge branch 'master' into error-warnings-1
vector-of-bool e5acd64
Fixed differing warning options between GNU and Clang
vector-of-bool 508ca3a
init-null in _test_hello_ok
vector-of-bool 9d8579c
Fix message in MongoC-Warnings
vector-of-bool 255c831
Only enable warnings in certain subdirectories
vector-of-bool 78531b6
Include mongoc-warnings in dist
vector-of-bool ca694e6
Disable some warnings on GCC < 5.0
vector-of-bool 59dc533
Use an OBJECT library for bundled zlib
vector-of-bool 39151f6
Disable compiler warnings for zlib
vector-of-bool 34d469e
Document MaintainerFlags versus MongoC-Warnings
vector-of-bool d151dbe
Update comments in mongoc-warnings
vector-of-bool File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#[[ | ||
This file sets warning options for the directories in which it is include()'d | ||
|
||
These warnings are intended to be ported to each supported platform, and | ||
especially for high-value warnings that are very likely to catch latent bugs | ||
early in the process before the code is even run. | ||
]] | ||
|
||
set (__is_gnu "$<C_COMPILER_ID:GNU>") | ||
set (__is_clang "$<OR:$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>>") | ||
set (__is_gnu_like "$<OR:${__is_gnu},${__is_clang}>") | ||
set (__is_msvc "$<C_COMPILER_ID:MSVC>") | ||
|
||
# "Old" GNU is GCC < 5, which is missing several warning options | ||
set (__is_old_gnu "$<AND:${__is_gnu},$<VERSION_LESS:$<C_COMPILER_VERSION>,5>>") | ||
set (__not_old_gnu "$<NOT:${__is_old_gnu}>") | ||
|
||
#[[ | ||
Define additional compile options, conditional on the compiler being used. | ||
Each option should be prefixed by `gnu:`, `clang:`, `msvc:`, or `gnu-like:`. | ||
Those options will be conditionally enabled for GCC, Clang, or MSVC. | ||
|
||
These options are attached to the source directory and its children. | ||
]] | ||
function (mongoc_add_platform_compile_options) | ||
foreach (opt IN LISTS ARGV) | ||
if (NOT opt MATCHES "^(gnu-like|gnu|clang|msvc):(.*)") | ||
message (SEND_ERROR "Invalid option '${opt}' (Should be prefixed by 'msvc:', 'gnu:', 'clang:', or 'gnu-like:'") | ||
continue () | ||
endif () | ||
if (CMAKE_MATCH_1 STREQUAL "gnu-like") | ||
add_compile_options ("$<${__is_gnu_like}:${CMAKE_MATCH_2}>") | ||
elseif (CMAKE_MATCH_1 STREQUAL gnu) | ||
add_compile_options ("$<${__is_gnu}:${CMAKE_MATCH_2}>") | ||
elseif (CMAKE_MATCH_1 STREQUAL clang) | ||
add_compile_options ("$<${__is_clang}:${CMAKE_MATCH_2}>") | ||
elseif (CMAKE_MATCH_1 STREQUAL "msvc") | ||
add_compile_options ("$<${__is_msvc}:${CMAKE_MATCH_2}>") | ||
else () | ||
message (SEND_ERROR "Invalid option to mongoc_add_platform_compile_options(): '${opt}'") | ||
endif () | ||
endforeach () | ||
endfunction () | ||
|
||
if (CMAKE_VERSION VERSION_LESS 3.3) | ||
# On older CMake versions, we'll just always pass the warning options, even | ||
# if the generate warnings for the C++ check file | ||
set (is_c_lang "1") | ||
else () | ||
# $<COMPILE_LANGUAGE> is only valid in CMake 3.3+ | ||
set (is_c_lang "$<COMPILE_LANGUAGE:C>") | ||
endif () | ||
|
||
# These below warnings should always be unconditional hard errors, as the code is | ||
# almost definitely broken | ||
mongoc_add_platform_compile_options ( | ||
# Implicit function or variable declarations | ||
gnu-like:$<${is_c_lang}:-Werror=implicit> msvc:/we4013 msvc:/we4431 | ||
# Missing return types/statements | ||
gnu-like:-Werror=return-type msvc:/we4716 | ||
# Incompatible pointer types | ||
gnu-like:$<$<AND:${is_c_lang},${__not_old_gnu}>:-Werror=incompatible-pointer-types> msvc:/we4113 | ||
# Integral/pointer conversions | ||
gnu-like:$<$<AND:${is_c_lang},${__not_old_gnu}>:-Werror=int-conversion> msvc:/we4047 | ||
# Discarding qualifiers | ||
gnu:$<$<AND:${is_c_lang},${__not_old_gnu}>:-Werror=discarded-qualifiers> | ||
clang:$<${is_c_lang}:-Werror=ignored-qualifiers> | ||
msvc:/we4090 | ||
# Definite use of uninitialized value | ||
gnu-like:-Werror=uninitialized msvc:/we4700 | ||
|
||
# Aside: Disable CRT insecurity warnings | ||
msvc:/D_CRT_SECURE_NO_WARNINGS | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious as to why we're removing this one, it seems to fall into the "almost always an error" category?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was moved into the
MongoC-Warnings.cmake
file. This just removes the redundancy.