]> granicus.if.org Git - clang/commitdiff
[c Sema]. Patch fixes pointer-bool-conversion warning on C code
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 18 Dec 2014 23:14:51 +0000 (23:14 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 18 Dec 2014 23:14:51 +0000 (23:14 +0000)
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

lib/Sema/SemaChecking.cpp
test/Sema/warn-tautological-compare.c

index 550474107c0acd40fe07138b3c992da270c6774b..55de70826bcf118ba116b04994108ee4798b93a9 100644 (file)
@@ -6685,11 +6685,11 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
   if (BO && BO->isLogicalOp()) {
     Expr *SubExpr = BO->getLHS()->IgnoreParenImpCasts();
     if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
-      ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc());
+      ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc());
 
     SubExpr = BO->getRHS()->IgnoreParenImpCasts();
     if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
-      ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc());
+      ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc());
   }
 
   if (const UnaryOperator *U = dyn_cast<UnaryOperator>(E))
index 2856eddc7b08a769a04a7ca4d2d7c06948373abd..247e7406398254dfad846fe55e2596d9dcb92559 100644 (file)
@@ -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);
+}