1 /* Test C11 alignment support. Test valid code using stdalign.h. */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
8 extern int strcmp (const char *, const char *);
10 extern void exit (int);
11 extern void abort (void);
13 alignas (alignof (max_align_t
)) char c
;
14 extern alignas (max_align_t
) char c
;
17 extern alignas (max_align_t
) short s
;
18 alignas (max_align_t
) short s
;
23 alignas (max_align_t
) long l
;
25 alignas (max_align_t
) long long ll
;
27 alignas (max_align_t
) float f
;
29 alignas (max_align_t
) double d
;
31 alignas (max_align_t
) _Complex
long double cld
;
33 alignas (0) alignas (int) alignas (char) char ca
[10];
35 alignas ((int) alignof (max_align_t
) + 0) int x
;
37 enum e
{ E
= alignof (max_align_t
) };
43 alignas (max_align_t
) long long auto_ll
;
46 /* Valid, but useless. */
47 alignas (0) struct s
; /* { dg-warning "useless" } */
50 #error "alignas not defined"
54 #error "alignof not defined"
57 #ifndef __alignas_is_defined
58 #error "__alignas_is_defined not defined"
61 #if __alignas_is_defined != 1
62 #error "__alignas_is_defined not 1"
65 #ifndef __alignof_is_defined
66 #error "__alignof_is_defined not defined"
69 #if __alignof_is_defined != 1
70 #error "__alignof_is_defined not 1"
74 #define xstr(x) str(x)
76 const char *s1
= xstr(alignas
);
77 const char *s2
= xstr(alignof
);
78 const char *s3
= xstr(__alignas_is_defined
);
79 const char *s4
= xstr(__alignof_is_defined
);
84 if (strcmp (s1
, "_Alignas") != 0)
86 if (strcmp (s2
, "_Alignof") != 0)
88 if (strcmp (s3
, "1") != 0)
90 if (strcmp (s4
, "1") != 0)