[llvm-bugs] [Bug 33771] New diagnostic -Wzero-as-null-pointer-constant warns on macros expanded from system headers.

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 22 03:04:20 PDT 2018


Martin Ejdestig <marejde at gmail.com> changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
                 CC|                            |marejde at gmail.com
         Resolution|FIXED                       |---

--- Comment #5 from Martin Ejdestig <marejde at gmail.com> ---
I am reopening this. It still occurs with Clang 6.0 in googletest even if
-isystem is used. It works as expected with GCC (no warning). A git clone of
googletest is checked out in external/googletest.

$ cat foo.cpp:

#include <gtest/gtest.h>

TEST(Foo, Bar)
        EXPECT_EQ(0, 1);

$ clang++ -Werror -Wzero-as-null-pointer-constant -isystem
external/googletest/googletest/include -o 'foo.o' -c foo.cpp
foo.cpp:5:12: error: zero as null pointer constant
        EXPECT_EQ(0, 1);
external/googletest/googletest/include/gtest/gtest.h:1924:55: note: expanded
from macro 'EXPECT_EQ'
                      EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
note: expanded from macro 'GTEST_IS_NULL_LITERAL_'
    (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
external/googletest/googletest/include/gtest/gtest_pred_impl.h:162:23: note:
expanded from macro 'EXPECT_PRED_FORMAT2'
external/googletest/googletest/include/gtest/gtest_pred_impl.h:147:17: note:
expanded from macro 'GTEST_PRED_FORMAT2_'
  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
external/googletest/googletest/include/gtest/gtest_pred_impl.h:77:52: note:
expanded from macro 'GTEST_ASSERT_'
  if (const ::testing::AssertionResult gtest_ar = (expression)) \
1 error generated.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180422/afda487c/attachment-0001.html>

More information about the llvm-bugs mailing list