[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / GH95854.cpp
blobaa470c6ac8e5b4175e5963ead74aa69796ff7f28
1 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
3 struct A {
4 union {
5 int n = 0;
6 int m;
7 };
8 };
9 const A a;
11 struct B {
12 union {
13 struct {
14 int n = 5;
15 int m;
19 const B b; // expected-error {{default initialization of an object of const type 'const B' without a user-provided default constructor}}
21 struct S {
22 int i;
23 int j;
26 struct T {
27 T() = default;
30 struct C {
31 union {
32 S s;
36 struct D {
37 union {
38 T s;
42 const C c; // expected-error {{default initialization of an object of const type 'const C' without a user-provided default constructor}}
43 const D d; // expected-error {{default initialization of an object of const type 'const D' without a user-provided default constructor}}
45 struct E {
46 union {
47 int n;
48 int m=0;
51 const E e;