Author: stulova Date: Fri Dec 11 09:23:00 2015 New Revision: 255339 URL: http://llvm.org/viewvc/llvm-project?rev=255339&view=rev Log: Reverting r255337 as it seems to kill bots. Needs investigation.
Removed: cfe/trunk/test/SemaOpenCL/null_literal.cl Modified: cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=255339&r1=255338&r2=255339&view=diff ============================================================================== --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Fri Dec 11 09:23:00 2015 @@ -3293,20 +3293,9 @@ Expr::isNullPointerConstant(ASTContext & // Check that it is a cast to void*. if (const PointerType *PT = CE->getType()->getAs<PointerType>()) { 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); } } Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=255339&r1=255338&r2=255339&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Dec 11 09:23:00 2015 @@ -8806,8 +8806,7 @@ QualType Sema::CheckCompareOperands(Expr 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<PointerType>(); if (!LHSPtr->isAddressSpaceOverlapping(*RHSType->getAs<PointerType>())) { Diag(Loc, Removed: cfe/trunk/test/SemaOpenCL/null_literal.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/null_literal.cl?rev=255338&view=auto ============================================================================== --- cfe/trunk/test/SemaOpenCL/null_literal.cl (original) +++ cfe/trunk/test/SemaOpenCL/null_literal.cl (removed) @@ -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; - -} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits