bitfields.go 839 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2020 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //
  5. // +build ignore
  6. package main
  7. // This file tests that we don't generate an incorrect field location
  8. // for a bitfield that appears aligned.
  9. /*
  10. struct bitfields {
  11. unsigned int B1 : 5;
  12. unsigned int B2 : 1;
  13. unsigned int B3 : 1;
  14. unsigned int B4 : 1;
  15. unsigned int Short1 : 16; // misaligned on 8 bit boundary
  16. unsigned int B5 : 1;
  17. unsigned int B6 : 1;
  18. unsigned int B7 : 1;
  19. unsigned int B8 : 1;
  20. unsigned int B9 : 1;
  21. unsigned int B10 : 3;
  22. unsigned int Short2 : 16; // alignment is OK
  23. unsigned int Short3 : 16; // alignment is OK
  24. };
  25. */
  26. import "C"
  27. type bitfields C.struct_bitfields