Misc fixes for -Wreorder:
1. Make it work correctly with anonymous unions.
2. Don't compute it if the warning isn't enabled.
3. Optimize the algorithm slightly to make it linear time in the
case where we don't produce any warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76630 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/warn-reorder-ctor-initialization.cpp b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
index 107c893..a199032 100644
--- a/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -73,4 +73,17 @@
// expected-note {{base 'struct V'}}
};
-
+class Anon {
+ int c; union {int a,b;}; int d;
+ Anon() : c(10), b(1), d(2) {}
+};
+class Anon2 {
+ int c; union {int a,b;}; int d;
+ Anon2() : c(2),
+ d(10), // expected-warning {{member 'd' will be initialized after}}
+ b(1) {} // expected-note {{field b}}
+};
+class Anon3 {
+ union {int a,b;};
+ Anon3() : b(1) {}
+};