[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer
Bevin Hansson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 6 01:39:27 PDT 2018
ebevhan added a comment.
When I try the test case on our downstream (and when compiling for our target with an extra flag that enables a bunch of OpenCL-related address space code), I get:
ascrash.c:5:12: error: comparison between ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *') which
are pointers to non-overlapping address spaces
return x < y ? x : y;
~ ^ ~
ascrash.c:5:16: error: conditional operator with the second and third operands of type ('__attribute__((address_space(1))) char *' and
'__attribute__((address_space(2))) char *') which are pointers to non-overlapping address spaces
return x < y ? x : y;
^ ~ ~
A lot of address space code is hidden behind LangOptions.OpenCL.
================
Comment at: lib/Sema/SemaExpr.cpp:6464
LangAS RAddrSpace = rhQual.getAddressSpace();
if (S.getLangOpts().OpenCL) {
// OpenCL v1.1 s6.5 - Conversion between pointers to distinct address
----------------
Here is an OpenCL condition.
================
Comment at: lib/Sema/SemaExpr.cpp:6473
S.Diag(Loc,
diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
<< LHSTy << RHSTy << 2 << LHS.get()->getSourceRange()
----------------
Aren't these the errors you actually want?
================
Comment at: lib/Sema/SemaExpr.cpp:8860
// if both are pointers check if operation is valid wrt address spaces
if (S.getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
const PointerType *lhsPtr = LHSExpr->getType()->getAs<PointerType>();
----------------
Here is another OpenCL AS error.
================
Comment at: lib/Sema/SemaExpr.cpp:10204
// Treat NULL constant as a special case in OpenCL.
if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
const PointerType *LHSPtr = LHSType->getAs<PointerType>();
----------------
And another.
Repository:
rC Clang
https://reviews.llvm.org/D50278
More information about the cfe-commits
mailing list