summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2011-08-05 00:22:34 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2011-08-05 00:22:34 +0000
commit3c48990a46ef8f21e87a387d634dbf3e13de1280 (patch)
tree80f6405bed6b9b10f4a3ef6158814a2f0fe28e66 /clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
parent91e82dd47734ecd8a190a0e10b2283bae34319ef (diff)
downloadbcm5719-llvm-3c48990a46ef8f21e87a387d634dbf3e13de1280.tar.gz
bcm5719-llvm-3c48990a46ef8f21e87a387d634dbf3e13de1280.zip
Extend memset/memcpy/memmove checking to include memcmp
llvm-svn: 136950
Diffstat (limited to 'clang/test/SemaCXX/warn-memset-bad-sizeof.cpp')
-rw-r--r--clang/test/SemaCXX/warn-memset-bad-sizeof.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp b/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
index 90ac50472e9..f4876ab442f 100644
--- a/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
+++ b/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
@@ -3,6 +3,7 @@
extern "C" void *memset(void *, int, unsigned);
extern "C" void *memmove(void *s1, const void *s2, unsigned n);
extern "C" void *memcpy(void *s1, const void *s2, unsigned n);
+extern "C" void *memcmp(void *s1, const void *s2, unsigned n);
struct S {int a, b, c, d;};
typedef S* PS;
@@ -51,6 +52,11 @@ void f(Mat m, const Foo& const_foo, char *buffer) {
memcpy(0, &s, sizeof(&s)); // \
// expected-warning {{argument to 'sizeof' in 'memcpy' call is the same expression as the source}}
+ memmove(ps, 0, sizeof(ps)); // \
+ // expected-warning {{argument to 'sizeof' in 'memmove' call is the same expression as the destination}}
+ memcmp(ps, 0, sizeof(ps)); // \
+ // expected-warning {{argument to 'sizeof' in 'memcmp' call is the same expression as the destination}}
+
/* Shouldn't warn */
memset((void*)&s, 0, sizeof(&s));
memset(&s, 0, sizeof(s));
@@ -99,3 +105,10 @@ void f(Mat m, const Foo& const_foo, char *buffer) {
memcpy(&foo, &arr, sizeof(Foo));
memcpy(&arr, &foo, sizeof(Foo));
}
+
+namespace ns {
+void memset(void* s, char c, int n);
+void f(int* i) {
+ memset(i, 0, sizeof(i));
+}
+}
OpenPOWER on IntegriCloud