[PATCH] D134461: [Clang] Diagnose an error when trying to deferencing void pointers in C

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 23 02:27:39 PDT 2022


junaire marked 3 inline comments as done.
junaire added a comment.

> So I thought 'isAddressOfOperand' might be good enough for this, is this not the case?

Yeah, that works, I somehow missed it ;D Thank you, Erich!



================
Comment at: clang/lib/Sema/SemaExpr.cpp:14541
+      Kind = diag::ext_typecheck_indirection_through_void_pointer;
+    else if (S.getLangOpts().C99 && !IsAfterAmp)
+      Kind = diag::warn_deference_void_pointer;
----------------
aaron.ballman wrote:
> junaire wrote:
> > I don't know why we don't have `getLangOpts().C89`. I'm a bit confused about how we deal with different C standards...
> This trips up folks somewhat often, unfortunately! All of the language mode options are cumulative, so if the user specifies C11, then C99 and C11 will both be true. However, we don't have an explicit C89 language mode, instead we rely on `!CPlusPlus` to tell us we're in C mode and `!C99` to tell us we're in C89 mode. Does that make sense?
Thanks for the explanation! That works for me!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134461/new/

https://reviews.llvm.org/D134461



More information about the cfe-commits mailing list