attr-aligned.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
  2. int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
  3. int y __attribute__((aligned(1 << 29))); // expected-error {{requested alignment must be 268435456 bytes or smaller}}
  4. // PR3254
  5. short g0[3] __attribute__((aligned));
  6. short g0_chk[__alignof__(g0) == 16 ? 1 : -1];
  7. // <rdar://problem/6840045>
  8. typedef char ueber_aligned_char __attribute__((aligned(8)));
  9. struct struct_with_ueber_char {
  10. ueber_aligned_char c;
  11. };
  12. char a = 0;
  13. char a0[__alignof__(ueber_aligned_char) == 8? 1 : -1] = { 0 };
  14. char a1[__alignof__(struct struct_with_ueber_char) == 8? 1 : -1] = { 0 };
  15. char a2[__alignof__(a) == 1? : -1] = { 0 };
  16. char a3[sizeof(a) == 1? : -1] = { 0 };
  17. typedef long long __attribute__((aligned(1))) underaligned_longlong;
  18. char a4[__alignof__(underaligned_longlong) == 1 ?: -1] = {0};
  19. typedef long long __attribute__((aligned(1))) underaligned_complex_longlong;
  20. char a5[__alignof__(underaligned_complex_longlong) == 1 ?: -1] = {0};
  21. // rdar://problem/8335865
  22. int b __attribute__((aligned(2)));
  23. char b1[__alignof__(b) == 2 ?: -1] = {0};
  24. struct C { int member __attribute__((aligned(2))); } c;
  25. char c1[__alignof__(c) == 4 ?: -1] = {0};
  26. char c2[__alignof__(c.member) == 4 ?: -1] = {0};
  27. struct D { int member __attribute__((aligned(2))) __attribute__((packed)); } d;
  28. char d1[__alignof__(d) == 2 ?: -1] = {0};
  29. char d2[__alignof__(d.member) == 2 ?: -1] = {0};
  30. struct E { int member __attribute__((aligned(2))); } __attribute__((packed));
  31. struct E e;
  32. char e1[__alignof__(e) == 2 ?: -1] = {0};
  33. char e2[__alignof__(e.member) == 2 ?: -1] = {0};
  34. typedef char overaligned_char __attribute__((aligned(16)));
  35. typedef overaligned_char array_with_overaligned_char[11];
  36. typedef char array_with_align_attr[11] __attribute__((aligned(16)));
  37. char f0[__alignof__(array_with_overaligned_char) == 16 ? 1 : -1] = { 0 };
  38. char f1[__alignof__(array_with_align_attr) == 16 ? 1 : -1] = { 0 };
  39. array_with_overaligned_char F2;
  40. char f2[__alignof__(F2) == 16 ? 1 : -1] = { 0 };
  41. array_with_align_attr F3;
  42. char f3[__alignof__(F3) == 16 ? 1 : -1] = { 0 };