[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / FixIt / fixit-cxx-init-order.cpp
blobf39c8bf2a15c87bbb8ae5e8e43c5622c7f59f7c9
1 // Due to the fix having multiple edits we can't use
2 // '-fdiagnostics-parseable-fixits' to determine if fixes are correct. However,
3 // running fixit recompile with 'Werror' should fail if the fixes are invalid.
5 // RUN: %clang_cc1 %s -Werror=reorder-ctor -fixit-recompile -fixit-to-temporary
6 // RUN: %clang_cc1 %s -Wreorder-ctor -verify -verify-ignore-unexpected=note
8 struct Foo {
9 int A, B, C;
11 Foo() : A(1), B(3), C(2) {}
12 Foo(int) : A(1), C(2), B(3) {} // expected-warning {{field 'C' will be initialized after field 'B'}}
13 Foo(unsigned) : C(2), B(3), A(1) {} // expected-warning {{initializer order does not match the declaration order}}
16 struct Bar : Foo {
17 int D, E, F;
19 Bar() : Foo(), D(1), E(2), F(3) {}
20 Bar(int) : D(1), E(2), F(3), Foo(4) {} // expected-warning {{field 'F' will be initialized after base 'Foo'}}
21 Bar(unsigned) : F(3), E(2), D(1), Foo(4) {} // expected-warning {{initializer order does not match the declaration order}}