On Fri, May 11, 2012 at 3:10 PM, Matt Beaumont-Gay <[email protected]>wrote:
> Author: matthewbg > Date: Fri May 11 17:10:59 2012 > New Revision: 156653 > > URL: http://llvm.org/viewvc/llvm-project?rev=156653&view=rev > Log: > Merge branch 'format-string-braced-init' > I'm almost disappointed we didn't get something more humorous / embarrassing from the git side of your git-svn commit log. ;] > > 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=156653&r1=156652&r2=156653&view=diff > > ============================================================================== > --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) > +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri May 11 17:10:59 2012 > @@ -1569,10 +1569,16 @@ > } > > 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 > > Modified: cfe/trunk/test/Sema/format-strings.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=156653&r1=156652&r2=156653&view=diff > > ============================================================================== > --- cfe/trunk/test/Sema/format-strings.c (original) > +++ cfe/trunk/test/Sema/format-strings.c Fri May 11 17:10:59 2012 > @@ -500,6 +500,10 @@ > 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 > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
