Adjust scan string for PIE
[official-gcc.git] / gcc / testsuite / gcc.dg / c11-align-2.c
bloba1750ac547a14bcb0951e7d56a1f79017d46e057
1 /* Test C11 alignment support. Test valid code using stdalign.h. */
2 /* { dg-do run } */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
5 #include <stdalign.h>
6 #include <stddef.h>
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;
15 extern char c;
17 extern alignas (max_align_t) short s;
18 alignas (max_align_t) short s;
20 alignas (int) int i;
21 extern int i;
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) };
38 alignas (E) int y;
40 void
41 func (void)
43 alignas (max_align_t) long long auto_ll;
46 /* Valid, but useless. */
47 alignas (0) struct s; /* { dg-warning "useless" } */
49 #ifndef alignas
50 #error "alignas not defined"
51 #endif
53 #ifndef alignof
54 #error "alignof not defined"
55 #endif
57 #ifndef __alignas_is_defined
58 #error "__alignas_is_defined not defined"
59 #endif
61 #if __alignas_is_defined != 1
62 #error "__alignas_is_defined not 1"
63 #endif
65 #ifndef __alignof_is_defined
66 #error "__alignof_is_defined not defined"
67 #endif
69 #if __alignof_is_defined != 1
70 #error "__alignof_is_defined not 1"
71 #endif
73 #define str(x) #x
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);
81 int
82 main (void)
84 if (strcmp (s1, "_Alignas") != 0)
85 abort ();
86 if (strcmp (s2, "_Alignof") != 0)
87 abort ();
88 if (strcmp (s3, "1") != 0)
89 abort ();
90 if (strcmp (s4, "1") != 0)
91 abort ();