]> granicus.if.org Git - clang/commitdiff
Heh, funny thing, 'void' isn't a POD type. Nice of us to suggest it to
authorChandler Carruth <chandlerc@gmail.com>
Wed, 27 Apr 2011 18:48:59 +0000 (18:48 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 27 Apr 2011 18:48:59 +0000 (18:48 +0000)
silence this warning. ;]

Fixed that obvious bug and added a bit more testing as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130318 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/SemaCXX/warn-non-pod-memset.cpp

index 6b219612d14127752e6e91f89b3afd6b3e7db089..7ee0eac370b9febfdb7b525b4fe63b735db0c107 100644 (file)
@@ -1810,7 +1810,7 @@ void Sema::CheckMemsetArguments(const CallExpr *Call) {
   QualType DestTy = Dest->getType();
   if (const PointerType *DestPtrTy = DestTy->getAs<PointerType>()) {
     QualType PointeeTy = DestPtrTy->getPointeeType();
-    if (!PointeeTy->isPODType()) {
+    if (!PointeeTy->isPODType() && !PointeeTy->isVoidType()) {
       DiagRuntimeBehavior(
         Dest->getExprLoc(), Dest,
         PDiag(diag::warn_non_pod_memset)
index 03e626e70877f3d85e09861e1ba72820e64d260f..97bbdc27cc4962c9b28a32552e8a3c970ae9c01c 100644 (file)
@@ -32,7 +32,16 @@ void test_warn() {
       // expected-note {{explicitly cast the pointer to silence this warning}}
 }
 
-void test_nowarn() {
+void test_nowarn(void *void_ptr) {
+  int i, *iptr;
+  float y;
+  char c;
+
+  memset(&i, 0, sizeof i);
+  memset(&iptr, 0, sizeof iptr);
+  memset(&y, 0, sizeof y);
+  memset(&c, 0, sizeof c);
+  memset(void_ptr, 0, 42);
   memset(&s1, 0, sizeof s1);
   memset(&s2, 0, sizeof s2);
   memset(&s3, 0, sizeof s3);