forked from OSchip/llvm-project
Merge branch 'format-string-braced-init'
llvm-svn: 156653
This commit is contained in:
parent
93303819ac
commit
d873508975
|
@ -1569,10 +1569,16 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, Expr **Args,
|
|||
}
|
||||
|
||||
if (isConstant) {
|
||||
if (const Expr *Init = VD->getAnyInitializer())
|
||||
if (const Expr *Init = VD->getAnyInitializer()) {
|
||||
// Look through initializers like const char c[] = { "foo" }
|
||||
if (const InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
|
||||
if (InitList->isStringLiteralInit())
|
||||
Init = InitList->getInit(0)->IgnoreParenImpCasts();
|
||||
}
|
||||
return SemaCheckStringLiteral(Init, Args, NumArgs,
|
||||
HasVAListArg, format_idx, firstDataArg,
|
||||
Type, /*inFunctionCall*/false);
|
||||
}
|
||||
}
|
||||
|
||||
// For vprintf* functions (i.e., HasVAListArg==true), we add a
|
||||
|
|
|
@ -500,6 +500,10 @@ void pr9751() {
|
|||
printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
|
||||
|
||||
printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
|
||||
|
||||
// Test braced char[] initializers.
|
||||
const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}}}
|
||||
printf(kFormat18, 0); // expected-warning{{format specifies type}}
|
||||
}
|
||||
|
||||
// PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx
|
||||
|
|
Loading…
Reference in New Issue