aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2012-05-11 22:10:59 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2012-05-11 22:10:59 +0000
commite2c60667d1bc29b7e148f9c9828dcbdbfc5b82b0 (patch)
tree3af9169e1273e9c2fce9fa7b7b3f3b3ae8e9efe0 /lib/Sema/SemaChecking.cpp
parent91338cf4129cfdb85af7e9ef396ab09621da10ec (diff)
Merge branch 'format-string-braced-init'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index bc4452f125..eddb612fc6 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -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