Jordan Rose | f70a886 | 2012-06-30 21:33:57 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=__alignof %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=_Alignof %s |
Peter Collingbourne | 82d0b0a | 2011-09-29 18:04:28 +0000 | [diff] [blame] | 3 | |
| 4 | _Alignas(3) int align_illegal; //expected-error {{requested alignment is not a power of 2}} |
| 5 | _Alignas(int) char align_big; |
| 6 | _Alignas(1) int align_small; // FIXME: this should be rejected |
| 7 | _Alignas(1) unsigned _Alignas(8) int _Alignas(1) align_multiple; |
| 8 | |
| 9 | struct align_member { |
| 10 | _Alignas(8) int member; |
| 11 | }; |
| 12 | |
| 13 | typedef _Alignas(8) char align_typedef; // FIXME: this should be rejected |
| 14 | |
Jordan Rose | f70a886 | 2012-06-30 21:33:57 +0000 | [diff] [blame] | 15 | _Static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong"); |
| 16 | _Static_assert(alignof(align_small) == 1, "j's alignment is wrong"); |
| 17 | _Static_assert(alignof(align_multiple) == 8, "l's alignment is wrong"); |
| 18 | _Static_assert(alignof(struct align_member) == 8, "quuux's alignment is wrong"); |
Peter Collingbourne | 82d0b0a | 2011-09-29 18:04:28 +0000 | [diff] [blame] | 19 | _Static_assert(sizeof(struct align_member) == 8, "quuux's size is wrong"); |
Jordan Rose | f70a886 | 2012-06-30 21:33:57 +0000 | [diff] [blame] | 20 | _Static_assert(alignof(align_typedef) == 8, "typedef's alignment is wrong"); |