From: Anastasia Stulova Date: Fri, 11 Dec 2015 15:23:00 +0000 (+0000) Subject: Reverting r255337 as it seems to kill bots. Needs investigation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c6f9fcfe42aa81667288eb9c2b3685da1a29a1b;p=clang Reverting r255337 as it seems to kill bots. Needs investigation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255339 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index b09824483a..69b1121f3d 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -3293,20 +3293,9 @@ Expr::isNullPointerConstant(ASTContext &Ctx, // Check that it is a cast to void*. if (const PointerType *PT = CE->getType()->getAs()) { QualType Pointee = PT->getPointeeType(); - Qualifiers Q = Pointee.getQualifiers(); - // In OpenCL v2.0 generic address space acts as a placeholder - // and should be ignored. - bool IsASValid = true; - if (Ctx.getLangOpts().OpenCLVersion >= 200) { - if (Pointee.getAddressSpace() == LangAS::opencl_generic) - Q.removeAddressSpace(); - else - IsASValid = false; - } - - if (IsASValid && !Q.hasQualifiers() && - Pointee->isVoidType() && // to void* - CE->getSubExpr()->getType()->isIntegerType()) // from int. + if (!Pointee.hasQualifiers() && + Pointee->isVoidType() && // to void* + CE->getSubExpr()->getType()->isIntegerType()) // from int. return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC); } } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 9bbc304e2e..b479ee497f 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -8806,8 +8806,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS, /*isError*/false); } if (LCanPointeeTy != RCanPointeeTy) { - // Treat NULL constant as a special case in OpenCL. - if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) { + if (getLangOpts().OpenCL) { const PointerType *LHSPtr = LHSType->getAs(); if (!LHSPtr->isAddressSpaceOverlapping(*RHSType->getAs())) { Diag(Loc, diff --git a/test/SemaOpenCL/null_literal.cl b/test/SemaOpenCL/null_literal.cl deleted file mode 100644 index 2fb287270f..0000000000 --- a/test/SemaOpenCL/null_literal.cl +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -verify %s -// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s - -#define NULL ((void*)0) - -void foo(){ - -global int* ptr1 = NULL; - -global int* ptr2 = (global void*)0; - -constant int* ptr3 = NULL; - -constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *' with an expression of type '__global void *' changes address space of pointer}} - -#ifdef CL20 -// Accept explicitly pointer to generic address space in OpenCL v2.0. -global int* ptr5 = (generic void*)0; -#endif - -global int* ptr6 = (local void*)0; // expected-error{{initializing '__global int *' with an expression of type '__local void *' changes address space of pointer}} - -bool cmp = ptr1 == NULL; - -cmp = ptr1 == (local void*)0; // expected-error{{comparison between ('__global int *' and '__local void *') which are pointers to non-overlapping address spaces}} - -cmp = ptr3 == NULL; - -}