Douglas Gregor | 69837be | 2010-02-11 18:18:11 +0000 | [diff] [blame] | 1 | typedef int Int; |
| 2 | typedef float Float; |
| 3 | |
Douglas Gregor | 7eeb597 | 2010-02-11 19:21:55 +0000 | [diff] [blame] | 4 | // Matches |
Douglas Gregor | 69837be | 2010-02-11 18:18:11 +0000 | [diff] [blame] | 5 | struct S0 { |
| 6 | Int field1; |
| 7 | Float field2; |
| 8 | }; |
| 9 | |
| 10 | struct S0 x0; |
| 11 | |
Douglas Gregor | 7eeb597 | 2010-02-11 19:21:55 +0000 | [diff] [blame] | 12 | // Mismatch in field type |
Douglas Gregor | 69837be | 2010-02-11 18:18:11 +0000 | [diff] [blame] | 13 | struct S1 { |
| 14 | Int field1; |
| 15 | int field2; |
| 16 | }; |
| 17 | |
| 18 | struct S1 x1; |
Douglas Gregor | 7eeb597 | 2010-02-11 19:21:55 +0000 | [diff] [blame] | 19 | |
| 20 | // Mismatch in tag kind. |
| 21 | struct S2 { int i; float f; } x2; |
| 22 | |
| 23 | // Missing fields |
| 24 | struct S3 { int i; float f; double d; } x3; |
| 25 | |
| 26 | // Extra fields |
| 27 | struct S4 { int i; } x4; |
| 28 | |
| 29 | // Bit-field matches |
| 30 | struct S5 { int i : 8; unsigned j : 8; } x5; |
| 31 | |
| 32 | // Bit-field mismatch |
| 33 | struct S6 { int i : 8; unsigned j : 8; } x6; |
| 34 | |
| 35 | // Bit-field mismatch |
| 36 | struct S7 { int i : 8; unsigned j : 8; } x7; |
Douglas Gregor | 2579105 | 2010-02-12 00:09:27 +0000 | [diff] [blame] | 37 | |
| 38 | // Incomplete type |
| 39 | struct S8 *x8; |
| 40 | |
| 41 | // Incomplete type |
| 42 | struct S9 { int i; float f; } *x9; |
| 43 | |
| 44 | // Incomplete type |
| 45 | struct S10 *x10; |
| 46 | |
Douglas Gregor | 3996e24 | 2010-02-15 22:01:00 +0000 | [diff] [blame] | 47 | // Matches |
Douglas Gregor | 8cdbe64 | 2010-02-12 23:44:20 +0000 | [diff] [blame] | 48 | struct ListNode { |
| 49 | int value; |
| 50 | struct ListNode *Next; |
| 51 | } xList; |
Douglas Gregor | 3996e24 | 2010-02-15 22:01:00 +0000 | [diff] [blame] | 52 | |
| 53 | // Mismatch due to struct used internally |
| 54 | struct DeepError { |
| 55 | int value; |
| 56 | struct DeeperError { int i; int f; } *Deeper; |
| 57 | } xDeep; |
Douglas Gregor | b4964f7 | 2010-02-15 23:54:17 +0000 | [diff] [blame] | 58 | |
| 59 | // Matches |
| 60 | struct { |
| 61 | Int i; |
| 62 | float f; |
| 63 | } x11; |
Gabor Horvath | 5558ba2 | 2017-04-03 09:30:20 +0000 | [diff] [blame] | 64 | |
| 65 | // Matches |
| 66 | typedef struct { |
| 67 | Int i; |
| 68 | float f; |
| 69 | } S12; |
| 70 | |
| 71 | S12 x12; |
| 72 | |
| 73 | // Mismatch |
| 74 | typedef struct { |
| 75 | Float i; // Mismatch here. |
| 76 | float f; |
| 77 | } S13; |
| 78 | |
| 79 | S13 x13; |
Aleksei Sidorin | 499de6c | 2018-04-05 15:31:49 +0000 | [diff] [blame] | 80 | |
| 81 | // Matches |
| 82 | struct Unnamed { |
| 83 | union { |
| 84 | struct { |
| 85 | int i; |
| 86 | } S; |
| 87 | struct { |
| 88 | float i; |
| 89 | } R; |
| 90 | } U; |
| 91 | } x14; |
| 92 | |
| 93 | // Matches |
| 94 | struct DeepUnnamed { |
| 95 | union { |
| 96 | union { |
| 97 | struct { |
| 98 | long i; |
| 99 | } S; |
| 100 | struct { |
| 101 | int i; |
| 102 | } R; |
| 103 | } U1; |
| 104 | union { |
| 105 | struct { |
| 106 | long i; |
| 107 | } S; |
| 108 | struct { |
| 109 | float i; |
| 110 | } T; |
| 111 | } U2; |
| 112 | } U; |
| 113 | struct { |
| 114 | long i; |
| 115 | } V; |
| 116 | } x15; |
| 117 | |
| 118 | // Mismatch due to unnamed struct used internally |
| 119 | struct DeepUnnamedError { |
| 120 | union { |
| 121 | union { |
| 122 | struct { |
| 123 | long i; |
| 124 | } S; |
| 125 | struct { |
| 126 | int i; |
| 127 | } R; |
| 128 | } U1; |
| 129 | union { |
| 130 | struct { |
| 131 | long i; // Mismatch here. |
| 132 | } S; |
| 133 | struct { |
| 134 | float i; |
| 135 | } T; |
| 136 | } U2; |
| 137 | } U; |
| 138 | struct { |
| 139 | long i; |
| 140 | } V; |
| 141 | } x16; |