]> granicus.if.org Git - clang/commitdiff
fix a bug handling the gnu ?: extension. Patch by Storlek on IRC,
authorChris Lattner <sabre@nondot.org>
Tue, 22 Dec 2009 06:00:13 +0000 (06:00 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 22 Dec 2009 06:00:13 +0000 (06:00 +0000)
who prefers to be stealthy and mysterious.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91888 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/Sema/format-strings.c

index 28de5005f8a825fa5e3a23ee79bf187c6c2ad9b1..74ea1cc3cddb6677cec98169e9e854f30f60736a 100644 (file)
@@ -800,7 +800,7 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
   switch (E->getStmtClass()) {
   case Stmt::ConditionalOperatorClass: {
     const ConditionalOperator *C = cast<ConditionalOperator>(E);
-    return SemaCheckStringLiteral(C->getLHS(), TheCall,
+    return SemaCheckStringLiteral(C->getTrueExpr(), TheCall,
                                   HasVAListArg, format_idx, firstDataArg)
         && SemaCheckStringLiteral(C->getRHS(), TheCall,
                                   HasVAListArg, format_idx, firstDataArg);
index 1ad4bda10a4e6aa587786108784a5aaeb167a3bb..67081b5e260357fc6fb77bc8e5469bd763733363 100644 (file)
@@ -50,6 +50,7 @@ void check_conditional_literal(const char* s, int i) {
   printf(i == 1 ? "yes" : "no"); // no-warning
   printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
   printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}}
+  printf("yes" ?: "no %d", 1); // expected-warning{{more data arguments than '%' conversions}}
 }
 
 void check_writeback_specifier()