rjmccall added a reviewer: rsmith.
rjmccall added a comment.

Top-level qualifiers aren't normally meaningful on pr-values.

The C standard says that casts are to the unqualified type:

  N2454 6.5.4p5: Preceding an expression by a parenthesized type name converts 
the value of the expression to the unqualified version of the named type.

The C++ standard does not appear to have similar wording.  On the other hand, 
the C++ standard says that e.g. "The result of the expression `(T) 
cast-expression` is of type `T`", and similarly for the other casts, which is 
clearly just wrong if `T` is a reference type; the wording clarifies that the 
expression is an l-value or x-value if the type is a reference but doesn't 
remove the reference-ness of the expression type as it must, unless that's done 
by some other clause at a distance.  CC'ing Richard.

It makes sense to me that qualifiers on the cast type ought to be uniformly and 
silently ignored, including address space qualifiers.  C++ has a very strange 
feature of allowing qualifiers on class types in particular circumstances, so 
we might need to be permissive about that, although that's tricky for address 
spaces because (unlike with `const` or `volatile`) we cannot in fact allocate a 
temporary in an arbitrary address space.

I agree that this should be done uniformly, not just in OpenCL, unless OpenCL 
wants rules that differ from what we think they ought to be in general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102689

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

Reply via email to