Debian Codegraph @

clang/test/SemaCXX/GH95854.cpp

raw
1 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
2
3 struct A {
4 union {
5 int n = 0;
6 int m;
7 };
8 };
9 const A a;
10
11 struct B {
12 union {
13 struct {
14 int n = 5;
15 int m;
16 };
17 };
18 };
19 const B b; // expected-error {{default initialization of an object of const type 'const B' without a user-provided default constructor}}
20
21 struct S {
22 int i;
23 int j;
24 };
25
26 struct T {
27 T() = default;
28 };
29
30 struct C {
31 union {
32 S s;
33 };
34 };
35
36 struct D {
37 union {
38 T s;
39 };
40 };
41
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}}
44
45 struct E {
46 union {
47 int n;
48 int m=0;
49 };
50 };
51 const E e;