Congcong Cai 2f1a0df72a
[clang][sema] Fixed a crash when mixture of designated and non-designated initializers in union (#114424)
Fixed: #113855
When the first init element is invalid, StructuredList can be empty.
It cause illegal state if we still set initialized field.
2024-11-04 22:28:07 +08:00

16 lines
417 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
struct S {};
union U {
S x;
float y;
};
void f() {
new U{0,.y=1};
// expected-warning@-1 {{mixture of designated and non-designated initializers in the same initializer list is a C99 extension}}
// expected-note@-2 {{first non-designated initializer is here}}
// expected-error@-3 {{initializer for aggregate with no elements requires explicit braces}}
}