-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Fix Clang warnings #1433
Fix Clang warnings #1433
Conversation
@dsacre Thank you for this contribution. googletest can not suport all warning flags combinations for all compilers. Given the wide usage this is not practical nor needed. |
@gennadiycivil These changes are not to appease a single overzealous compiler, but address actual (albeit minor) code quality issues in Google Test. For example, ValueArray's use of an implicitly defined copy constructor has been deprecated by the language standard since C++11. I'd also like to mention that due to Google Test's heavy use of preprocessor macros, some of these warnings "leak" into user code. In other words, there is no way to silence these warnings without disabling the corresponding compiler flags for the user's code base as well. |
@dsacre I am re-opening this PR, could you please provide more information with real use cases / test cases to support "some of these warnings "leak" into user code. In other words, there is no way to silence these warnings without disabling the corresponding compiler flags for the user's code base as well.". |
@gennadiycivil I appreciate you taking another look at this. What I mean by "leaking" is this: Normally, if you don't want to see warnings from a third-party library while compiling your own code (with warnings of your choice enabled), you have two options: Specify the library's header search path with
However, in some cases (specifically the issue fixed by 1811dd2) neither option will work, because the offending code is inside a macro. By the time the compiler gets to it, the preprocessor will already have inserted it into my own code every time I use The other instances of I'm a little on the fence about fd38c01. Clang basically warns about a rule-of-three violation, but apparently the only reason copy-assignment is forbidden were warnings from MSVC. That commit was nine years ago, so I wonder if it's even still relevant. |
@@ -79,6 +79,8 @@ class ValueArray1 { | |||
return ValuesIn(array); | |||
} | |||
|
|||
ValueArray1(const ValueArray1& other) : v1_(other.v1_) {} |
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 haven't looked into what this ValueArray
does, so I could easily be wrong, but couldn't this line just be:
ValueArray1(const ValueArray1&) = default;
because this explicit copy constructor sure looks like what = default;
would generate from the compiler. In which case every other change in this commit could also be a single = default;
line, and not have to explicitly copy each member of other
into *this
based on the particular ValueArray
. No?
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 is a C++11 feature but GoogleTest keeps compatibility with C++03.
At my company we also hit the issue being fixed in 1811dd2 all the time when using parameterized tests. We usually end up wrapping the entire test in an anonymous namespace to avoid it, but it would be nice not to have to (remember to) do that. |
@dsacre @hadrielk @pavelkryukov Apologies for the wait. Could you please resolve conflicts. |
fd38c01
to
bdd3062
Compare
@gennadiycivil I've rebased the branch onto master, and also amended one of the commits to add another missing declaration for a flag that was recently introduced. |
@dsacre Thank you for the changes. Please provide test run output "before" and "after" that clearly illustrates the changes and their results |
@gennadiycivil This is the output I get when compiling Google Test itself (the flags
Additionally, when compiling the following example code:
...this is what Clang says:
With the proposed changes, the compiler is silent in both cases. |
@dsacre Could you please resolve conflicts |
Commit 6a26e47 changed the formatting of INSTANTIATE_TEST_CASE_P() in the generated header file only. This commit reverts to the formatting produced by running "pump gtest-param-test.h.pump", which seems to be more consistent with the rest of the file.
Fix -Wmissing-variable-declarations warnings from Clang.
Fix Clang warning: | warning: no previous extern declaration for non-static variable 'g_argvs' | [-Wmissing-variable-declarations]
Add declarations for install_failure_signal_handler and flagfile. Fix Clang warnings: | warning: no previous extern declaration for non-static variable | 'FLAGS_gtest_install_failure_signal_handler' [-Wmissing-variable-declarations] | warning: no previous extern declaration for non-static variable | 'FLAGS_gtest_flagfile' | [-Wmissing-variable-declarations]
Fix Clang warning: | warning: definition of implicit copy constructor for 'ValueArray2<bool, bool>' | is deprecated because it has a user-declared copy assignment operator [-Wdeprecated]
d56071d
to
13c5230
Compare
@gennadiycivil done, rebased on current master. |
Explicitly silence an intended case fall-through in cxa_demangle.cxx and update googletest submodule to pull in google/googletest#1433
This branch fixes a series of warnings that occur when building with Clang, with the
-Wdeprecated
and-Wmissing-variable-declarations
flags enabled.