forked from OSchip/llvm-project
Enhance checking for null format string literal to take into account __null. Fixes <rdar://problem/8269537>.
llvm-svn: 150260
This commit is contained in:
parent
a16ae59722
commit
dde2adec89
|
@ -1381,6 +1381,7 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, Expr **Args,
|
|||
inFunctionCall);
|
||||
}
|
||||
|
||||
case Stmt::GNUNullExprClass:
|
||||
case Stmt::IntegerLiteralClass:
|
||||
// Technically -Wformat-nonliteral does not warn about this case.
|
||||
// The behavior of printf and friends in this case is implementation
|
||||
|
|
|
@ -39,3 +39,14 @@ void h(int *i) {
|
|||
printf(foo.gettext("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
|
||||
printf(Foo::gettext_static("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
|
||||
}
|
||||
|
||||
// Test handling __null for format string literal checking.
|
||||
extern "C" {
|
||||
int test_null_format(const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
|
||||
}
|
||||
|
||||
void rdar8269537(const char *f)
|
||||
{
|
||||
test_null_format(__null); // no-warning
|
||||
test_null_format(f); // expected-warning {{not a string literal}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue