This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG89e56e732d5e: [Clang] Don't warn if deferencing void pointers in unevaluated context (authored by junaire).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D134702/new/ https://reviews.llvm.org/D134702 Files: clang/lib/Sema/SemaExpr.cpp clang/test/Analysis/misc-ps.m clang/test/Sema/no-warn-void-ptr-uneval.c Index: clang/test/Sema/no-warn-void-ptr-uneval.c =================================================================== --- /dev/null +++ clang/test/Sema/no-warn-void-ptr-uneval.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s + +// expected-no-diagnostics +void foo(void *vp) { + sizeof(*vp); + sizeof(*(vp)); + void inner(typeof(*vp)); +} Index: clang/test/Analysis/misc-ps.m =================================================================== --- clang/test/Analysis/misc-ps.m +++ clang/test/Analysis/misc-ps.m @@ -133,7 +133,7 @@ void* q; if (!flag) { - if (sizeof(*q) == 1) // expected-warning {{ISO C does not allow indirection on operand of type 'void *'}} + if (sizeof(*q) == 1) return; // Infeasibe. *p = 1; // no-warning 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)) + if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext()))) S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer) << LO.CPlusPlus << OpTy << Op->getSourceRange(); }
Index: clang/test/Sema/no-warn-void-ptr-uneval.c =================================================================== --- /dev/null +++ clang/test/Sema/no-warn-void-ptr-uneval.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s + +// expected-no-diagnostics +void foo(void *vp) { + sizeof(*vp); + sizeof(*(vp)); + void inner(typeof(*vp)); +} Index: clang/test/Analysis/misc-ps.m =================================================================== --- clang/test/Analysis/misc-ps.m +++ clang/test/Analysis/misc-ps.m @@ -133,7 +133,7 @@ void* q; if (!flag) { - if (sizeof(*q) == 1) // expected-warning {{ISO C does not allow indirection on operand of type 'void *'}} + if (sizeof(*q) == 1) return; // Infeasibe. *p = 1; // no-warning 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)) + if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext()))) S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer) << LO.CPlusPlus << OpTy << Op->getSourceRange(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits