This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Don't warn if deferencing void pointers in unevaluated context
ClosedPublic

Authored by junaire on Sep 26 2022, 9:58 PM.

Details

Summary

After https://reviews.llvm.org/D134461, Clang will diagnose a warning if
trying to deference void pointers in C mode. However, this causes a lot
of noises when compiling a 5.19.11 Linux kernel.

This patch reduces the warning by marking deferencing void pointers in
unevaluated context OK, like sizeof(*void_ptr), typeof(*void_ptr)
and etc.

Fixes https://github.com/ClangBuiltLinux/linux/issues/1720

Signed-off-by: Jun Zhang <jun@junz.org>

Diff Detail

Event Timeline

junaire created this revision.Sep 26 2022, 9:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2022, 9:58 PM
junaire requested review of this revision.Sep 26 2022, 9:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2022, 9:58 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thanks a lot for fixing this! I took it for a spin against the Linux kernel and all instances of -Wvoid-ptr-dereference disappeared :)

Thanks a lot for fixing this! I took it for a spin against the Linux kernel and all instances of -Wvoid-ptr-dereference disappeared :)

Awesome! Glad to hear this fixed your problem!

nickdesaulniers accepted this revision.Sep 27 2022, 11:39 AM

Thanks for the quick fix!

This revision is now accepted and ready to land.Sep 27 2022, 11:39 AM
This revision was landed with ongoing or failed builds.Sep 27 2022, 9:30 PM
This revision was automatically updated to reflect the committed changes.
clang/lib/Sema/SemaExpr.cpp
14539

Sorry, I should have asked more about this subexpresssion.

Our CI is still red for older branches of the Linux kernel ("stable" branches) because the kernel only recently started using -std=gnu11 from -std=gnu89.

Why is this considered an error for -std=gnu89?

clang/lib/Sema/SemaExpr.cpp
14539