From 45ca9fe8fcc6a67036369624f57576be22ac7bbd Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 10 Sep 2018 15:43:20 +0200 Subject: 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. --- cparser/Cutil.mli | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cparser/Cutil.mli') diff --git a/cparser/Cutil.mli b/cparser/Cutil.mli index 3f8d8dcd..dc9dc0cc 100644 --- a/cparser/Cutil.mli +++ b/cparser/Cutil.mli @@ -58,8 +58,8 @@ val erase_attributes_type : Env.t -> typ -> typ (* Erase the attributes of the given type. *) val change_attributes_type : Env.t -> (attributes -> attributes) -> typ -> typ (* Apply the given function to the top-level attributes of the given type *) -val has_std_alignas : attributes -> bool - (* Do the attributes contain the C11 _Alignas attribute *) +val has_std_alignas : Env.t -> typ -> bool + (* Do the attributes of the type contain the C11 _Alignas attribute *) type attribute_class = | Attr_name (* Attribute applies to the names being declared *) -- cgit