r282124 - [Sema] Fix PR30481: crash on checking printf args.
George Burgess IV via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 21 17:00:27 PDT 2016
Author: gbiv
Date: Wed Sep 21 19:00:26 2016
New Revision: 282124
URL: http://llvm.org/viewvc/llvm-project?rev=282124&view=rev
Log:
[Sema] Fix PR30481: crash on checking printf args.
We were falling through from one case to another in a switch statement.
Oops.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings.c
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=282124&r1=282123&r2=282124&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 21 19:00:26 2016
@@ -4194,9 +4194,9 @@ checkFormatStringExpr(Sema &S, const Exp
goto tryAgain;
}
}
-
- return SLCT_NotALiteral;
}
+
+ return SLCT_NotALiteral;
}
case Stmt::UnaryOperatorClass: {
const UnaryOperator *UnaOp = cast<UnaryOperator>(E);
Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=282124&r1=282123&r2=282124&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Wed Sep 21 19:00:26 2016
@@ -687,3 +687,8 @@ void test_char_pointer_arithmetic(int b)
printf(s7 + 3, ""); // expected-warning{{more '%' conversions than data arguments}}
// expected-note at -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 at format-strings.c:*{{passing argument to parameter here}} expected-note{{to avoid this}}
+}
More information about the cfe-commits
mailing list