Skip to content

Commit

Permalink
[Clang] fix -Wvoid-ptr-dereference for gnu89
Browse files Browse the repository at this point in the history
Follow up to D134702; it looks like we were still warning for gnu89
mode.

Link: https://reviews.llvm.org/D134702
Link: ClangBuiltLinux/linux#1720 (comment)

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D135090
  • Loading branch information
nickdesaulniers committed Oct 4, 2022
1 parent 11d7507 commit 2dbfd06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaExpr.cpp
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions 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) {
Expand Down

0 comments on commit 2dbfd06

Please sign in to comment.