diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/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(); } diff --git a/clang/test/Sema/no-warn-void-ptr-uneval.c b/clang/test/Sema/no-warn-void-ptr-uneval.c --- 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) {