struct2.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Matches
  2. struct S0 {
  3. int field1;
  4. float field2;
  5. };
  6. struct S0 x0;
  7. // Mismatch in field type
  8. struct S1 {
  9. int field1;
  10. float field2;
  11. };
  12. struct S1 x1;
  13. // Mismatch in tag kind.
  14. union S2 { int i; float f; } x2;
  15. // Missing fields
  16. struct S3 { int i; float f; } x3;
  17. // Extra fields
  18. struct S4 { int i; float f; } x4;
  19. // Bit-field matches
  20. struct S5 { int i : 8; unsigned j : 8; } x5;
  21. // Bit-field mismatch
  22. struct S6 { int i : 8; unsigned j; } x6;
  23. // Bit-field mismatch
  24. struct S7 { int i : 8; unsigned j : 16; } x7;
  25. // Incomplete type
  26. struct S8 { int i; float f; } *x8;
  27. // Incomplete type
  28. struct S9 *x9;
  29. // Incomplete type
  30. struct S10 *x10;
  31. // Matches
  32. struct ListNode {
  33. int value;
  34. struct ListNode *Next;
  35. } xList;
  36. // Mismatch due to struct used internally
  37. struct DeepError {
  38. int value;
  39. struct DeeperError { int i; float f; } *Deeper;
  40. } xDeep;
  41. // Matches
  42. struct {
  43. int i;
  44. float f;
  45. } x11;
  46. // Matches
  47. typedef struct {
  48. int i;
  49. float f;
  50. } S12;
  51. S12 x12;
  52. // Mismatch
  53. typedef struct {
  54. int i; // Mismatch here.
  55. float f;
  56. } S13;
  57. S13 x13;
  58. // Matches
  59. struct Unnamed {
  60. union {
  61. struct {
  62. int i;
  63. } S;
  64. struct {
  65. float i;
  66. } R;
  67. } U;
  68. } x14;
  69. // Matches
  70. struct DeepUnnamed {
  71. union {
  72. union {
  73. struct {
  74. long i;
  75. } S;
  76. struct {
  77. int i;
  78. } R;
  79. } U1;
  80. union {
  81. struct {
  82. long i;
  83. } S;
  84. struct {
  85. float i;
  86. } T;
  87. } U2;
  88. } U;
  89. struct {
  90. long i;
  91. } V;
  92. } x15;
  93. // Mismatch due to unnamed struct used internally
  94. struct DeepUnnamedError {
  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. float i; // Mismatch here.
  107. } S;
  108. struct {
  109. float i;
  110. } T;
  111. } U2;
  112. } U;
  113. struct {
  114. long i;
  115. } V;
  116. } x16;