brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 1d9b918 Raw
65 lines · cpp
1// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s2 3namespace PR61118 {4 5union S {6  struct {7    int a;8  };9};10 11void f(int x, auto) {12  const S result {13    .a = x14  };15}16 17void g(void) {18  f(0, 0);19}20 21} // end namespace PR6111822 23namespace GH65143 {24struct Inner {25  int a;26};27 28struct Outer {29  struct {30    Inner inner;31  };32};33 34template <int val> void f() {35  constexpr Outer x{.inner = {val}};36  static_assert(x.inner.a == val);37}38 39void bar() { f<4>(); }40}41 42namespace GH62156 {43union U1 {44   int x;45   float y;46};47 48struct NonTrivial {49  NonTrivial();50  ~NonTrivial();51};52 53union U2 {54   NonTrivial x;55   float y;56};57 58void f() {59   U1 u{.x=2,  // expected-note {{previous initialization is here}}60        .y=1}; // expected-error {{initializer partially overrides prior initialization of this subobject}}61   new U2{.x = NonTrivial{}, // expected-note {{previous initialization is here}}62          .y=1}; // expected-error {{initializer would partially override prior initialization of object of type 'NonTrivial' with non-trivial destruction}}63}64}65