<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/225039>225039</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] Assignment to an `_Atomic` vector asserts in VectorExprEvaluator during the overflow check ("Must both be vector types")
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          captainnemo9292
      </td>
    </tr>
</table>

<pre>
    https://godbolt.org/z/adscn6MrG (`-O0`)

```c
typedef unsigned a __attribute__((vector_size(16)));
void b() { a c; _Atomic a d; d = c; }
```
```
clang: clang/lib/AST/ExprConstant.cpp:12239: bool {anonymous}::VectorExprEvaluator::VisitBinaryOperator(const clang::BinaryOperator*): Assertion `LHS->getType()->isVectorType() && RHS->getType()->isVectorType() && "Must both be vector types"' failed.
 #10 (anonymous namespace)::VectorExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*)
 #12 EvaluateVector(...)
 #15 clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const
 #16 clang::Sema::CheckForIntOverflow(clang::Expr const*)
 #17 clang::Sema::CheckCompletedExpr(...)
```

`CheckForIntOverflow` evaluates the full expression. The assignment has vector type, so `EvaluateVector` is used, but the left operand's type is `_Atomic(a)`, which `isVectorType()` does not see through. `d += c` asserts the same way; a non-atomic `d = c`, a scalar `_Atomic int`, and `_Atomic a d = c;` (initialisation instead of assignment) are fine. Valid code, no diagnostics before the assertion. Clang trunk, assertions build.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVVFv4zYM_jXMC1FDlhMnfsiDk162ATsUWIt7DWSJjrVTJEOS0-Z-_SDb2eW6bsMGCIhikfzIT59IEYI-WaItrHawelyIIXbOb6Xoo9DW0tlVvOKLxqnrtouxD1DUwA_ADyenGmdi5vwJ-OEb8INQQdrys_8JgW-gZA9PDEoGvA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