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 | d30ef87f34015d18bde20b9632032d0063d761aa (patch) | |
tree | 31a6cae84c6cbc35bfd20e1a9a5af9a4a60ada6f /test/Sema/format-strings.c | |
parent | ee49d0496bb8ff2bbf479bb7fbcfbdc71eed7461 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings.c')
-rw-r--r-- | test/Sema/format-strings.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 16d4943cda..19c29db343 100644 --- a/test/Sema/format-strings.c +++ b/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; |