Homec4science

Googletest export

Authored by Abseil Team <absl-team@google.com> on Mar 4 2019, 17:10.

Description

Googletest export

Fix emission of -Wzero-as-null-pointer-constant when comparing integers.

The following code fails to compile:

#pragma clang diagnostic error "-Wzero-as-null-pointer-constant"
void foo() {

EXPECT_EQ(0, 0);

}

This happens because gtest checks the first argument to EXPECT_EQ and
ASSERT_EQ is a null pointer constant. The magic it does to do this causes the
warning to be emitted.

This patch removes that check. It replaces the explicit check with a Compare
overload that can only be selected when 0 or nullptr is passed on the LHS
with a pointer on the right.

This patch does not suppress -Wzero-as-null-pointer-constant when users
are actually using it as NULL.

PiperOrigin-RevId: 236654634

Details

Committed
Gennadiy Civil <misterg@google.com>Mar 5 2019, 14:39
Pushed
trottetDec 4 2019, 13:52
Parents
R9484:a1dd07786b9a: Googletest export
Branches
Unknown
Tags
Unknown

Event Timeline

Gennadiy Civil <misterg@google.com> committed R9484:3dd2e841c34b: Googletest export (authored by Abseil Team <absl-team@google.com>).Mar 5 2019, 14:39