[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / constexpr-single-element-array.cpp
blobf94a84bba064d7f4b46c916bdd5d5a4cdf591926
1 // RUN: %clang_cc1 -std=c++20 -verify %s
2 // RUN: %clang_cc1 -std=c++20 -verify -fexperimental-new-constant-interpreter %s
5 // This test makes sure that a single element array doesn't produce
6 // spurious errors during constexpr evaluation.
8 // expected-no-diagnostics
9 struct Sub { int x; };
11 struct S {
12 constexpr S() { Arr[0] = Sub{}; }
13 Sub Arr[1];
16 constexpr bool test() {
17 S s;
18 return true;
21 static_assert(test());