summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/warn-strlcpycat-size.c
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Sema/warn-strlcpycat-size.c')
-rw-r--r--clang/test/Sema/warn-strlcpycat-size.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/Sema/warn-strlcpycat-size.c b/clang/test/Sema/warn-strlcpycat-size.c
index e9e617488c4..34830120d5d 100644
--- a/clang/test/Sema/warn-strlcpycat-size.c
+++ b/clang/test/Sema/warn-strlcpycat-size.c
@@ -26,3 +26,30 @@ void f(void)
strlcpy((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
strlcpy(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
}
+
+// Don't issue FIXIT for flexible arrays.
+struct S {
+ int y;
+ char x[];
+};
+
+void flexible_arrays(struct S *s) {
+ char str[] = "hi";
+ strlcpy(s->x, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
+}
+
+// Don't issue FIXIT for destinations of size 1.
+void size_1() {
+ char z[1];
+ char str[] = "hi";
+
+ strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
+}
+
+// Support VLAs.
+void vlas(int size) {
+ char z[size];
+ char str[] = "hi";
+
+ strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
+}
OpenPOWER on IntegriCloud