summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/format-strings.c
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-08-07 09:13:19 +0000
committerHans Wennborg <hans@hanshq.net>2012-08-07 09:13:19 +0000
commitabc1e22d659e735af4946bc70762ece5391e4472 (patch)
tree5d23e66ddb30fc5f212abe17c1ff72794c843a72 /clang/test/Sema/format-strings.c
parentb1ab2a84f0eac4954e2769ace9c1c73ebce983e5 (diff)
downloadbcm5719-llvm-abc1e22d659e735af4946bc70762ece5391e4472.tar.gz
bcm5719-llvm-abc1e22d659e735af4946bc70762ece5391e4472.zip
Properly check length modfiers for %n in format strings.
llvm-svn: 161408
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r--clang/test/Sema/format-strings.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index aff996fed3e..86b9296108c 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -90,6 +90,33 @@ void check_writeback_specifier()
char *b;
printf("%n", b); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
printf("%n", &x); // no-warning
+
+ printf("%hhn", (signed char*)0); // no-warning
+ printf("%hhn", (char*)0); // no-warning
+ printf("%hhn", (unsigned char*)0); // no-warning
+ printf("%hhn", (int*)0); // expected-warning{{format specifies type 'signed char *' but the argument has type 'int *'}}
+
+ printf("%hn", (short*)0); // no-warning
+ printf("%hn", (unsigned short*)0); // no-warning
+ printf("%hn", (int*)0); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}}
+
+ printf("%n", (int*)0); // no-warning
+ printf("%n", (unsigned int*)0); // no-warning
+ printf("%n", (char*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
+
+ printf("%ln", (long*)0); // no-warning
+ printf("%ln", (unsigned long*)0); // no-warning
+ printf("%ln", (int*)0); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+
+ printf("%lln", (long long*)0); // no-warning
+ printf("%lln", (unsigned long long*)0); // no-warning
+ printf("%lln", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
+
+ printf("%qn", (long long*)0); // no-warning
+ printf("%qn", (unsigned long long*)0); // no-warning
+ printf("%qn", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
+
+ printf("%Ln", 0); // expected-warning{{length modifier 'L' results in undefined behavior or no effect with 'n' conversion specifier}}
}
void check_invalid_specifier(FILE* fp, char *buf)
OpenPOWER on IntegriCloud