struct1.c 1.8 KB

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