aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/GH95854.cpp
blob: aa470c6ac8e5b4175e5963ead74aa69796ff7f28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s

struct A {
  union {
    int n = 0;
    int m;
  };
};
const A a;

struct B {
  union {
    struct {
      int n = 5;
      int m;
    };
  };
};
const B b; // expected-error {{default initialization of an object of const type 'const B' without a user-provided default constructor}}

struct S {
  int i;
  int j;
};

struct T {
  T() = default;
};

struct C {
  union {
    S s;
  };
};

struct D {
  union {
    T s;
  };
};

const C c; // expected-error {{default initialization of an object of const type 'const C' without a user-provided default constructor}}
const D d; // expected-error {{default initialization of an object of const type 'const D' without a user-provided default constructor}}

struct E {
  union {
    int n;
    int m=0;
  };
};
const E e;