aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cutil.mli
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2017-01-31 16:13:03 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2017-01-31 16:13:03 +0100
commit8b178cf0b7e9dcc823ad164a6856032627b3bc6f (patch)
tree7a3e057c5c2d119f34e975addc1f582786879391 /cparser/Cutil.mli
parentf1df4fcf671ac0cdb4ddf51d2af20b3eb10af61e (diff)
downloadcompcert-kvx-8b178cf0b7e9dcc823ad164a6856032627b3bc6f.tar.gz
compcert-kvx-8b178cf0b7e9dcc823ad164a6856032627b3bc6f.zip
Revised elaboration of attributes
The treatment of attributes in the current CompCert is often surprising. For example, attribute(xxx) char * x; is parsed as "x is a pointer to a (char modified by attribute "xxx")", while for most attributes (e.g. section attributes) the expected meaning is "x, modified by attribute "xxx", has type pointer to char". CompCert's current treatment comes from the fact that attributes are processed very much like the standard type modifiers `const` and `volatile`, i.e. const char * x; is really "x is a pointer to a const char", not "x is a const pointer to char". This experiment introduces a distinction between type-related attributes (which include the standard modifiers `const` and `volatile`) and other attributes. The other, non-type-related attributes are "floated up" during elaboration so that they apply to the variable or function being declared or defined. In the examples above, attribute(xxx) char * x; // "attribute(xxx)" applies to "x" const char * x; // "const" applies to "char" This may be a step in the right direction but is not the final story. In particular, the `packed` attribute is special-cased when applied to `struct`, like it was before, and future attributes concerning calling conventions would need to be floated up to function types but not higher than that.
Diffstat (limited to 'cparser/Cutil.mli')
-rw-r--r--cparser/Cutil.mli2
1 files changed, 2 insertions, 0 deletions
diff --git a/cparser/Cutil.mli b/cparser/Cutil.mli
index edff9ee1..4906a8a8 100644
--- a/cparser/Cutil.mli
+++ b/cparser/Cutil.mli
@@ -54,6 +54,8 @@ val change_attributes_type : Env.t -> (attributes -> attributes) -> typ -> typ
(* Apply the given function to the top-level attributes of the given type *)
val attr_is_type_related: attribute -> bool
(* Is an attribute type-related (true) or variable-related (false)? *)
+val attr_is_struct_related: attribute -> bool
+ (* Is an attribute related to structs, unions and enum (true) or not (false)? *)
val attr_inherited_by_members: attribute -> bool
(* Is an attribute of a composite inherited by members of the composite? *)
val strip_attributes_type: typ -> attribute list -> typ