googletest
googletest copied to clipboard
Fix nvc++ compiler warnings
When I build the current stable branch (760060059fb746018a9849234e02dc9bf003861b) of the reference mdspan implementation (https://github.com/kokkos/mdspan) with nvc++ (either 22.7 or a pre-release version), I get a couple build warnings like the following.
".../tests/googletest-src/googletest/src/gtest-internal-inl.h", line 636: warning: unknown attribute "optimize" [unrecognized_attribute]
GTEST_NO_INLINE_ GTEST_NO_TAIL_CALL_;
^
Issue https://github.com/google/googletest/issues/3849 explains: GTest is using #elif __GNUC__ to protect use of __attribute__((optimize("no-optimize-sibling-calls"))). Many compilers that are not GCC define __GNUC__ to express some degree of compatibility with GCC extensions. This includes nvc++. nvc++ does not understand this attribute, so it emits a warning. My fix just disables use of that attribute if __NVCOMPILER is defined.
I've tested this fix with a pre-release (post-22.7) version of nvc++. It prevents the warning, and the reference mdspan implementation's tests build and run correctly.
Fixes #3849.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
I think we have a CLA -- I'll have to look into this.