[PATCH] D149000: Update with warning message for comparison to NULL pointer
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 26 05:46:36 PDT 2023
aaron.ballman added inline comments.
================
Comment at: clang/test/Sema/conditional-expr.c:89
char x;
- return ((((&x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
}
----------------
The C99 warning should not be dropped -- that was a valid pedantic diagnostic: https://godbolt.org/z/Tz3zGY8d4
================
Comment at: clang/test/SemaCXX/constant-expression-cxx2a.cpp:252
// ... but in the complete object, the same is not true, so the runtime fails.
- static_assert(dynamic_cast<const A*>(static_cast<const C2*>(&g)) == nullptr);
+ static_assert(dynamic_cast<const A*>(static_cast<const C2*>(&g)) == nullptr); // expected-warning {{comparison of address of 'g' equal to a null pointer is always false}}
----------------
shafik wrote:
> I don't believe we should be emitting a diagnostic for this case. The `static_assert` passes. CC @aaron.ballman
Agreed, this new diagnostic should not be triggered
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149000/new/
https://reviews.llvm.org/D149000
More information about the cfe-commits
mailing list