| 1 | // RUN: %check_clang_tidy -std=c++98-or-later %s bugprone-tagged-union-member-count %t \ |
| 2 | // RUN: -config='{CheckOptions: { \ |
| 3 | // RUN: bugprone-tagged-union-member-count.StrictMode: false, \ |
| 4 | // RUN: }}' -- |
| 5 | |
| 6 | // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: tagged union has more data members (2) than tags (1) |
| 7 | struct Incorrect { |
| 8 | enum { |
| 9 | tags1, |
| 10 | } Tags; |
| 11 | union { |
| 12 | char A; |
| 13 | short B; |
| 14 | } Data; |
| 15 | }; |
| 16 | |
| 17 | struct CorrectBecauseStrictModeIsDisabled { // No warnings expected |
| 18 | enum { |
| 19 | tags1, |
| 20 | tags2, |
| 21 | tags3, |
| 22 | } Tags; |
| 23 | union { |
| 24 | char A; |
| 25 | short B; |
| 26 | } Data; |
| 27 | }; |
| 28 | |