[clang] [Clang][Sema] Prevent implicit casting Complex type to Vector (PR #187954)

Amr Hesham via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 22 14:22:00 PDT 2026


================
@@ -13073,9 +13073,12 @@ void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,
       if (SourceMgr.isInSystemMacro(CC) || Target->isBooleanType())
         return;
 
+      const Type *OriginalTargetTy = Context.getCanonicalType(T).getTypePtr();
       return DiagnoseImpCast(*this, E, T, CC,
                              getLangOpts().CPlusPlus
                                  ? diag::err_impcast_complex_scalar
+                             : OriginalTargetTy->isVectorType()
+                                 ? diag::err_impcast_incompatible_type
----------------
AmrDeveloper wrote:

Sure, I will move it to an if statement before

> I believe just calling T->isVectorType() is enough

T is TypeDef, so I think we need to desugar it first, then check if the actual type is vector



https://github.com/llvm/llvm-project/pull/187954


More information about the cfe-commits mailing list