From 813b70d6db54dbf149cfaa14ec7502142121d86f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 22 Dec 2009 06:00:13 +0000 Subject: [PATCH] fix a bug handling the gnu ?: extension. Patch by Storlek on IRC, 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 | 2 +- test/Sema/format-strings.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 28de5005f8..74ea1cc3cd 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -800,7 +800,7 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, switch (E->getStmtClass()) { case Stmt::ConditionalOperatorClass: { const ConditionalOperator *C = cast(E); - return SemaCheckStringLiteral(C->getLHS(), TheCall, + return SemaCheckStringLiteral(C->getTrueExpr(), TheCall, HasVAListArg, format_idx, firstDataArg) && SemaCheckStringLiteral(C->getRHS(), TheCall, HasVAListArg, format_idx, firstDataArg); diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 1ad4bda10a..67081b5e26 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -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() -- 2.40.0