<div class="gmail_quote">On Fri, May 11, 2012 at 3:10 PM, Matt Beaumont-Gay <span dir="ltr"><<a href="mailto:matthewbg@google.com" target="_blank">matthewbg@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: matthewbg<br>
Date: Fri May 11 17:10:59 2012<br>
New Revision: 156653<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=156653&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=156653&view=rev</a><br>
Log:<br>
Merge branch 'format-string-braced-init'<br></blockquote><div><br></div><div>I'm almost disappointed we didn't get something more humorous / embarrassing from the git side of your git-svn commit log. ;]</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaChecking.cpp<br>
    cfe/trunk/test/Sema/format-strings.c<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=156653&r1=156652&r2=156653&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=156653&r1=156652&r2=156653&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri May 11 17:10:59 2012<br>
@@ -1569,10 +1569,16 @@<br>
       }<br>
<br>
       if (isConstant) {<br>
-        if (const Expr *Init = VD->getAnyInitializer())<br>
+        if (const Expr *Init = VD->getAnyInitializer()) {<br>
+          // Look through initializers like const char c[] = { "foo" }<br>
+          if (const InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {<br>
+            if (InitList->isStringLiteralInit())<br>
+              Init = InitList->getInit(0)->IgnoreParenImpCasts();<br>
+          }<br>
           return SemaCheckStringLiteral(Init, Args, NumArgs,<br>
                                         HasVAListArg, format_idx, firstDataArg,<br>
                                         Type, /*inFunctionCall*/false);<br>
+        }<br>
       }<br>
<br>
       // For vprintf* functions (i.e., HasVAListArg==true), we add a<br>
<br>
Modified: cfe/trunk/test/Sema/format-strings.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=156653&r1=156652&r2=156653&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=156653&r1=156652&r2=156653&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/Sema/format-strings.c (original)<br>
+++ cfe/trunk/test/Sema/format-strings.c Fri May 11 17:10:59 2012<br>
@@ -500,6 +500,10 @@<br>
   printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}<br>
<br>
   printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}<br>
+<br>
+  // Test braced char[] initializers.<br>
+  const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}}}<br>
+  printf(kFormat18, 0); // expected-warning{{format specifies type}}<br>
 }<br>
<br>
 // PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>