[PATCH] D135090: [Clang] fix -Wvoid-ptr-dereference for gnu89

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 4 13:01:20 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2dbfd06f2a8b: [Clang] fix -Wvoid-ptr-dereference for gnu89 (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135090

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/no-warn-void-ptr-uneval.c


Index: clang/test/Sema/no-warn-void-ptr-uneval.c
===================================================================
--- clang/test/Sema/no-warn-void-ptr-uneval.c
+++ clang/test/Sema/no-warn-void-ptr-uneval.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=gnu89 %s
 
 // expected-no-diagnostics
 void foo(void *vp) {
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14536,7 +14536,7 @@
     //   [...] the expression to which [the unary * operator] is applied shall
     //   be a pointer to an object type, or a pointer to a function type
     LangOptions LO = S.getLangOpts();
-    if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext())))
+    if (LO.CPlusPlus || (!(LO.C99 && IsAfterAmp) && !S.isUnevaluatedContext()))
       S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
           << LO.CPlusPlus << OpTy << Op->getSourceRange();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135090.465128.patch
Type: text/x-patch
Size: 1099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221004/efb2674a/attachment.bin>


More information about the cfe-commits mailing list