[clang] 2dbfd06 - [Clang] fix -Wvoid-ptr-dereference for gnu89
Nick Desaulniers via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 4 13:01:15 PDT 2022
Author: Nick Desaulniers
Date: 2022-10-04T13:01:01-07:00
New Revision: 2dbfd06f2a8ba6cd7cc3f587808f1ea2c61ad2c7
URL: https://github.com/llvm/llvm-project/commit/2dbfd06f2a8ba6cd7cc3f587808f1ea2c61ad2c7
DIFF: https://github.com/llvm/llvm-project/commit/2dbfd06f2a8ba6cd7cc3f587808f1ea2c61ad2c7.diff
LOG: [Clang] fix -Wvoid-ptr-dereference for gnu89
Follow up to 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
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D135090
Added:
Modified:
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/no-warn-void-ptr-uneval.c
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index fca9240362e76..6d28a44952318 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14536,7 +14536,7 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK,
// [...] 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();
}
diff --git a/clang/test/Sema/no-warn-void-ptr-uneval.c b/clang/test/Sema/no-warn-void-ptr-uneval.c
index 2aed1180ab0da..cc93efcda68f1 100644
--- a/clang/test/Sema/no-warn-void-ptr-uneval.c
+++ b/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) {
More information about the cfe-commits
mailing list