diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-20 10:55:26 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-20 10:55:26 +0100 |
commit | 55937c177f90ecf0dea40c318d2f8d52fa69b55d (patch) | |
tree | 493a207959cd64f6b3419dc109d246df35b01e54 /cparser/Cabs.v | |
parent | efaf1cf1c47370ab23db190fc4c2c1f3ad05323e (diff) | |
download | compcert-55937c177f90ecf0dea40c318d2f8d52fa69b55d.tar.gz compcert-55937c177f90ecf0dea40c318d2f8d52fa69b55d.zip |
Implement offsetof via builtin.
The implementation of offsetof as macro in the form
((size_t) &((ty*) NULL)->member) has the problem that it cannot be
used everywhere were an integer constant expression is allowed,
for example in initiliazers of global variables and there is also
no check for the case that member is of bitifield type.
The new implementation adds a builtin function for this which is
replaced by an integer constant during elaboration.
Bug 20765
Diffstat (limited to 'cparser/Cabs.v')
-rw-r--r-- | cparser/Cabs.v | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/cparser/Cabs.v b/cparser/Cabs.v index d087e8c7..355c748e 100644 --- a/cparser/Cabs.v +++ b/cparser/Cabs.v @@ -142,6 +142,7 @@ with expression := (* Non-standard *) | EXPR_ALIGNOF : expression -> expression | TYPE_ALIGNOF : (list spec_elem * decl_type) -> expression + | BUILTIN_OFFSETOF : (list spec_elem * decl_type) -> string -> expression with constant := (* The string is the textual representation of the constant in |