================
@@ -12591,6 +12592,19 @@ void Sema::CheckImplicitConversion(Expr *E, QualType
T, SourceLocation CC,
if (auto VecTy = dyn_cast<VectorType>(Target))
Target = VecTy->getElementType().getTypePtr();
+ if (isa<ConstantMatrixType>(Source)) {
+ if (!isa<ConstantMatrixType>(Target)) {
+ return DiagnoseImpCast(*this, E, T, CC,
diag::warn_impcast_matrix_scalar);
+ } else if (getLangOpts().HLSL &&
----------------
llvm-beanz wrote:
Should this warning be emitted for "if source is a constant matrix and
destination is not" or "if source is a constant matrix and destination is a
scalar"? The latter seems more correct to me.
I'm also a bit unclear about the language mode requirements for this. I assume
this can't actually occur in non-HLSL code. If it can, we should have some
tests for the C/C++ exposure of this warning.
For the next block, I also suspect that we couldn't get this far with an AST
that isn't from HLSL source, but I'm not sure the `getLangOpts().HLSL` check is
really required there. I assume that if C/C++ ever had an implicit conversion
for matrix truncation they would also want the compiler to emit a warning
(@fhahn thoughts?).
Code style nit:
```suggestion
if (!isa<ConstantMatrixType>(Target))
return DiagnoseImpCast(*this, E, T, CC, diag::warn_impcast_matrix_scalar);
if (getLangOpts().HLSL &&
```
see: https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
https://github.com/llvm/llvm-project/pull/168915
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits