Yuxuan Chen e732d1ce86
[Clang] Fix ICE in SemaOpenMP with structured binding (#104822)
Fixes https://github.com/llvm/llvm-project/issues/104810.

Clang currently crashes on the following program:
```
struct S {
  int i;
};

auto [a] = S{1};

void foo() {
    a;
}
```
when `-fopenmp` is enabled. 

Because `a` is neither `VarDecl` nor `FieldDecl`. It's a `BindingDecl`
that's not handled in `SemaOpenMP.cpp`'s `getCanonicalDecl`. It appears
to me that this pattern matching is merely just for a refined return
type of the overrides. It can also be achieved with just using the
virtual `Decl::getCanonicalDecl()` instead. Do the final casting should
be safe for `ValueDecl`s.
2024-08-19 14:06:10 -07:00

13 lines
137 B
C++

// RUN: %clang_cc1 -fopenmp -fsyntax-only %s
// expected-no-diagnostics
struct S {
int i;
};
auto [a] = S{1};
void foo() {
a;
}