brintos

brintos / llvm-project-archived public Read only

0
0
Text · 983 B · b8c141a Raw
22 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=override,reorder -Werror=c99-designator %s2// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=override -Wno-reorder-init-list -Werror=initializer-overrides %s3// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=reorder -Wno-initializer-overrides -Werror=reorder-init-list %s4// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=good -Wno-c99-designator %s5// good-no-diagnostics6 7// Ensure that -Wc99-designator controls both -Winitializer-overrides and8// -Wreorder-init-list.9 10struct X {11  int a;12  int b;13};14 15void test() {16  X x{.a = 0,  // override-note {{previous initialization is here}}17      .a = 1}; // override-error {{initializer overrides prior initialization of this subobject}}18  X y{.b = 0,  // reorder-note {{previous initialization for field 'b' is here}}19      .a = 1}; // reorder-error {{ISO C++ requires field designators to be specified in declaration order; field 'b' will be initialized after field 'a'}}20}21 22