From: Fariborz Jahanian Date: Thu, 18 Dec 2014 23:14:51 +0000 (+0000) Subject: [c Sema]. Patch fixes pointer-bool-conversion warning on C code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6cc137611a0fbff1c80e8d577834f1cbdea9a336;p=clang [c Sema]. Patch fixes pointer-bool-conversion warning on C code when source range is incorrect causing the warning to be issued when it should not because expression is in a macro. rdar://19256338 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224549 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 550474107c..55de70826b 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -6685,11 +6685,11 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) { if (BO && BO->isLogicalOp()) { Expr *SubExpr = BO->getLHS()->IgnoreParenImpCasts(); if (!IsLogicalAndOperator || !isa(SubExpr)) - ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc()); + ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc()); SubExpr = BO->getRHS()->IgnoreParenImpCasts(); if (!IsLogicalAndOperator || !isa(SubExpr)) - ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc()); + ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc()); } if (const UnaryOperator *U = dyn_cast(E)) diff --git a/test/Sema/warn-tautological-compare.c b/test/Sema/warn-tautological-compare.c index 2856eddc7b..247e740639 100644 --- a/test/Sema/warn-tautological-compare.c +++ b/test/Sema/warn-tautological-compare.c @@ -77,4 +77,18 @@ void test3() { (!array && array[0])) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}} } - +// rdar://19256338 +#define SAVE_READ(PTR, RESULT) if( (PTR) && *(PTR) ) *RESULT=*PTR; + +// Source +typedef unsigned char Boolean; +struct HTTPClientPrivate +{ + Boolean readSuspended; +}; +typedef struct HTTPClientPrivate * HTTPClientRef; +static void _HTTPClientErrorHandler( HTTPClientRef me) +{ + Boolean result; + SAVE_READ(&me->readSuspended, &result); +}