[cfe-commits] r130770 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaCXX/warn-non-pod-memset.cpp

Douglas Gregor dgregor at apple.com
Tue May 3 11:11:37 PDT 2011


Author: dgregor
Date: Tue May  3 13:11:37 2011
New Revision: 130770

URL: http://llvm.org/viewvc/llvm-project?rev=130770&view=rev
Log:
Only check the use of memset() if we're refering to a C function named
'memset' with external linkage.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaCXX/warn-non-pod-memset.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=130770&r1=130769&r2=130770&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue May  3 13:11:37 2011
@@ -319,7 +319,9 @@
   }
 
   // Memset handling
-  if (FnInfo->isStr("memset"))
+  if (FnInfo->isStr("memset") && 
+      FDecl->getLinkage() == ExternalLinkage &&
+      (!getLangOptions().CPlusPlus || FDecl->isExternC()))
     CheckMemsetArguments(TheCall);
 
   return false;

Modified: cfe/trunk/test/SemaCXX/warn-non-pod-memset.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-non-pod-memset.cpp?rev=130770&r1=130769&r2=130770&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-non-pod-memset.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-non-pod-memset.cpp Tue May  3 13:11:37 2011
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wnon-pod-memset -verify %s
 
-extern void *memset(void *, int, unsigned);
+extern "C" void *memset(void *, int, unsigned);
 
 // Several POD types that should not warn.
 struct S1 {} s1;
@@ -61,3 +61,10 @@
   // Dead code shouldn't warn.
   if (false) memset(&x1, 0, sizeof x1);
 }
+
+namespace N {
+  void *memset(void *, int, unsigned);
+  void test_nowarn() {
+    N::memset(&x1, 0, sizeof x1);
+  }
+}





More information about the cfe-commits mailing list