From: George Burgess IV Date: Thu, 22 Sep 2016 00:00:26 +0000 (+0000) Subject: [Sema] Fix PR30481: crash on checking printf args. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b67e055cc7546d1c7bde880aa89353bfe6ce49b6;p=clang [Sema] Fix PR30481: crash on checking printf args. We were falling through from one case to another in a switch statement. Oops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282124 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 1e17afc06b..0604c5aeac 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -4194,9 +4194,9 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args, goto tryAgain; } } - - return SLCT_NotALiteral; } + + return SLCT_NotALiteral; } case Stmt::UnaryOperatorClass: { const UnaryOperator *UnaOp = cast(E); diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index a6b3a69936..5c332bd37a 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -687,3 +687,8 @@ void test_char_pointer_arithmetic(int b) { printf(s7 + 3, ""); // expected-warning{{more '%' conversions than data arguments}} // expected-note@-2{{format string is defined here}} } + +void PR30481() { + // This caused crashes due to invalid casts. + printf(1 > 0); // expected-warning{{format string is not a string literal}} expected-warning{{incompatible integer to pointer conversion}} expected-note@format-strings.c:*{{passing argument to parameter here}} expected-note{{to avoid this}} +}