aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression/alignas.c
diff options
context:
space:
mode:
authorBernhard Schommer <bschommer@users.noreply.github.com>2018-09-10 15:43:20 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-09-10 15:43:20 +0200
commit45ca9fe8fcc6a67036369624f57576be22ac7bbd (patch)
tree7f4e1e79a1abd7fccfdf965f872e9ae6b4437c52 /test/regression/alignas.c
parent49ecf8a3e5b5a4449f4bcbc1d6d4f55c8b5888be (diff)
downloadcompcert-kvx-45ca9fe8fcc6a67036369624f57576be22ac7bbd.tar.gz
compcert-kvx-45ca9fe8fcc6a67036369624f57576be22ac7bbd.zip
Attach _Alignas to names and refactor _Alignas checks (#133)
* Refactor common code of alignas. Instead of working on attributes the function now works directly on the type since the check always performed an extraction of attributes from a type. Bug 23393 * Attach _Alignas to the name. Bug 23393 * Attach "aligned" attributes to names So that __attribute((aligned(N))) remains consistent with _Alignas(N). gcc and clang apply "aligned" attributes to names, with a special case for typedefs: typedef __attribute((aligned(16))) int int_al_16; int_al_16 * p; __attribute((aligned(16))) int * q; For gcc, p is naturally-aligned pointer to 16-aligned int and q is 16-aligned pointer to naturally-aligned int. For CompCert with this commit, both p and q are 16-aligned pointers to naturally-aligned int. * Resurrect the alignment test involving typedef The test was removed because it involved an _Alignas in a typedef, which is no longer supported. However the same effect can be achieved with an "aligned" attribute, which is still supported in typedef.
Diffstat (limited to 'test/regression/alignas.c')
-rw-r--r--test/regression/alignas.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/test/regression/alignas.c b/test/regression/alignas.c
index 23966b59..777c13a5 100644
--- a/test/regression/alignas.c
+++ b/test/regression/alignas.c
@@ -7,7 +7,7 @@
#endif
#if __STDC_VERSION__ < 201100 && defined(__GNUC__)
-#define _Alignas(x) __attribute__((aligned(x)))
+#define _Alignas(x) __attribute((aligned(x)))
#endif
/* Base type */
@@ -20,10 +20,9 @@ _Alignas(16) int b[3];
typedef int int3[3];
_Alignas(16) int3 bb;
-#if 0
-typedef _Alignas(16) int int16;
+/* _Alignas is not allowed in typedefs but the "aligned" attribute is */
+typedef __attribute((aligned(16))) int int16;
int16 bbb[3];
-#endif
char filler2;
@@ -74,10 +73,8 @@ int main()
(unsigned) sizeof(b), ((unsigned) &b) & 0xF);
printf("bb: size = %u, address mod 16 = %u\n",
(unsigned) sizeof(bb), ((unsigned) &bb) & 0xF);
-#if 0
printf("bbb: size = %u, address mod 16 = %u\n",
(unsigned) sizeof(bbb), ((unsigned) &bbb) & 0xF);
-#endif
printf("c: size = %u, address mod 16 = %u\n",
(unsigned) sizeof(c), ((unsigned) &c) & 0xF);
printf("d: size = %u, address mod 64 = %u\n",