diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-01-12 23:09:09 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-01-12 23:09:09 +0000 |
commit | 6dfeb558979b44bc32a74a9849b39bdbdac96eb7 (patch) | |
tree | a0437e60bbe4c0999440b6c7a02236f7531bc79e /clang/test/Sema/format-strings.c | |
parent | b71fbeb19fc34e6568d1b66a45acb9d560fd4c52 (diff) | |
download | bcm5719-llvm-6dfeb558979b44bc32a74a9849b39bdbdac96eb7.tar.gz bcm5719-llvm-6dfeb558979b44bc32a74a9849b39bdbdac96eb7.zip |
Patch by Roman Divacky:
Extend string-literal checking for printf() format string to handle conditional
ternary operators where both sides are literals.
This fixes PR 3319: http://llvm.org/bugs/show_bug.cgi?id=3319
llvm-svn: 62117
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r-- | clang/test/Sema/format-strings.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index 16d4943cda5..19c29db343d 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -31,6 +31,12 @@ void check_string_literal( FILE* fp, const char* s, char *buf, ... ) { __builtin___vsnprintf_chk(buf,2,0,-1,global_fmt,ap); // expected-warning {{format string is not a string literal}} } +void check_conditional_literal(const char* s, int i) { + printf(i == 1 ? "yes" : "no"); // no-warning + printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning + printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning +} + void check_writeback_specifier() { int x; |