[PATCH] D135090: [Clang] fix -Wvoid-ptr-dereference for gnu89
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 3 10:47:24 PDT 2022
nickdesaulniers created this revision.
nickdesaulniers added reviewers: aaron.ballman, junaire.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Follow up to D134702 <https://reviews.llvm.org/D134702>; it looks like we were still warning for gnu89
mode.
Link: https://reviews.llvm.org/D134702
Link: https://github.com/ClangBuiltLinux/linux/issues/1720#issuecomment-1265738778
Signed-off-by: Nick Desaulniers <ndesaulniers at google.com>
Repository:
rG LLVM Github Monorepo
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.464737.patch
Type: text/x-patch
Size: 1099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221003/069d13ab/attachment.bin>
More information about the cfe-commits
mailing list