rjmccall added inline comments.

================
Comment at: clang/lib/Sema/SemaExpr.cpp:10090
   // if both are pointers check if operation is valid wrt address spaces
-  if (S.getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
+  if ((S.getLangOpts().OpenCL || S.getLangOpts().SYCLIsDevice) &&
+      isLHSPointer && isRHSPointer) {
----------------
Anastasia wrote:
> bader wrote:
> > Alternative approach would be to remove `S.getLangOpts().OpenCL` to enable 
> > this check for all modes.
> > 
> > @Anastasia, do you know if it's safe to do?
> If I look at embedded C (ISO/IEC TR 18037) s5.3 rules that we are following 
> largely in Clang I believe this is a universal rule!
> 
> Especially looking at the followong statement:
> 
> > Clause 6.5.6 - Additive operators, add another constraint paragraph: 
> > For subtraction, if the two operands are pointers into different address 
> > spaces, the address spaces must overlap. 
> 
> So I think that it should apply to at least OpenCL, C and C++.  I am 
> surprised though that this has not been fixed yet.
> 
> I am CCing @rjmccall and @jeroen.dobbelaere in case they have any more 
> insights on this.
> 
Yes, I agree, this should apply in all modes.

You should able to restructure the `isAddressSpaceOverlapping` function so that 
it can work directly on the address spaces of  `LHSPointeeTy` and 
`RHSPointeeTy`; the code will be both cleaner and faster.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80317/new/

https://reviews.llvm.org/D80317



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to