This is an archive of the discontinued LLVM Phabricator instance.

[Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test
ClosedPublic

Authored by kiloalphaindia on Jul 25 2023, 3:38 AM.

Details

Summary

Fixes:

/home/buildbots/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1526:11: warning: comparison of integer expressions of different signedness: ‘const unsigned int’ and ‘const int’ [-Wsign-compare]
/home/buildbots/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1526:11: warning: comparison of integer expressions of different signedness: ‘const long unsigned int’ and ‘const int’ [-Wsign-compare]

Diff Detail

Event Timeline

kiloalphaindia created this revision.Jul 25 2023, 3:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2023, 3:38 AM
Herald added a subscriber: shchenz. · View Herald Transcript
kiloalphaindia requested review of this revision.Jul 25 2023, 3:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2023, 3:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

See: https://lab.llvm.org/buildbot/#/builders/57/builds/28680

I couldn't reproduce this on my system. Anyone knows how to test it before merging?

Thanks for the quick fix. Any idea why it would only show up on ppc64 @aaron.ballman ?

It could also be a different version of gtest or so.

Thanks for the quick fix. Any idea why it would only show up on ppc64 @aaron.ballman ?

Not certain, to be honest. The diagnostic is enabled by -Wextra so I would have imagined this was enabled all over. My guess is that this bot was configured with -Werror whereas other bots showed the issue but as a warning.

Changes LGTM

cor3ntin accepted this revision.Jul 25 2023, 4:58 AM

I was able to confirm on my machine that the warnings are no longer emitted. They were there when i committed the initial patch, i just missed them. Sorry about that

This revision is now accepted and ready to land.Jul 25 2023, 4:58 AM
This revision was landed with ongoing or failed builds.Jul 25 2023, 4:58 AM
This revision was automatically updated to reflect the committed changes.

I had copied the warning-flags from the build-bot command line and ended up as follows:

-Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -Woverloaded-virtual -Wno-nested-anon-types -O2 -DNDEBUG -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -Wno-suggest-override

This obviously includes -Wextra ...
Still wondering, why I couldn't see the warning.
Which version of GTEST are you using?

shafik added a subscriber: shafik.Jul 26 2023, 3:44 PM
shafik added inline comments.
clang/unittests/libclang/LibclangTest.cpp
1232

Above you used 0u but here you changed the type to int, is there a reason why not to use 0u here as well?