aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
Commit message (Collapse)AuthorAgeFilesLines
* Use Printf.sprintf instead of Format.sprintf when possibleXavier Leroy2017-02-091-4/+4
| | | | Minor performance tweak. Printf is more efficient for plain formats involving no boxes.
* Revert broken change to Cutil.Bernhard Schommer2017-02-083-10/+10
| | | | | | The optional hex parameter only worked if the intconstant was also of unsigned kind. Hence it is better to have one function in Bitfields for this.
* Merge branch 'elaboration-of-attributes'Xavier Leroy2017-02-066-42/+129
|\
| * Preliminary support for the "noreturn" attributeXavier Leroy2017-02-061-11/+15
| | | | | | | | | | - Mark the "noreturn" attribute as related to function types, so that it is correctly attached to the nearest enclosing function type. - Add this attribute on functions declared / defined _Noreturn (with the C2011 keyword). The information is not used presently but could be useful later.
| * Refactor the classification of attributesXavier Leroy2017-02-035-23/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce Cutil.class_of_attribute to return the class of the given attribute: one among Attr_type attribute related to types (e.g. "aligned") Attr_struct attribute related to struct/union/enum types (e.g. "packed") Attr_function attribute related to function types (e.g. "noreturn") Attr_name attribute related to variable and function declarations (e.g. "section") Attr_unknown attribute was not declared Cutil.declare_attribute is used to associate a class to a custom attribute. Standard attributes (const, volatile, _Alignas, etc) are Attr_type. cfronted/C2C.ml: declare the few attributes that CompCert honors currently. cparser/GCC.ml: a bigger list of attributes taken from GCC, for reference only.
| * Use C99 syntax to print attributes over array typesXavier Leroy2017-02-011-4/+5
| | | | | | | | Before, we were doing C90, there was no official syntax for such attributes, and we used ours. With C99 we can use "ty [ attributes N ]" to print "array with attributes of N elements of type ty".
| * Regression: type attributes and array modifiersXavier Leroy2017-02-011-2/+4
| | | | | | | | | | | | | | Owing to the peculiarities of array types in Cutil.change_attributes_type, type-related attributes of the array element type were duplicated on the array type. E.g. elaborating 'const int a[10][5]' produced "a is an array of 5 const arrays of 10 const ints" instead of "a is an array of 5 arrays of 10 const ints"
| * Revised elaboration of attributesXavier Leroy2017-01-314-17/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Removed shadowing openBernhard Schommer2017-02-061-5/+5
| |
* | Remove shadowing openBernhard Schommer2017-02-061-1/+1
| |
* | Remove unused open.Bernhard Schommer2017-02-061-1/+0
| |
* | Cleanup opens.Bernhard Schommer2017-02-061-9/+8
| | | | | | | | | | | | The Printf is only needed for the identifier functions. Furthermore the new intconst from Cutil is used to generate the integer constant and shadowing of the open C is removed.
* | Generalized function to allow adding hex strings.Bernhard Schommer2017-02-062-4/+8
| | | | | | | | | | The intconst function comes with an optional parameter to add an hex string for later printing.
* | Remove all overriding opens in Elab.ml. Bug 19872Bernhard Schommer2017-02-031-2/+2
| |
* | Removed Cabshelper open and avoided shadowing.Bernhard Schommer2017-02-031-7/+6
| | | | | | | | | | | | | | | | The Cabshelper is only used in 4 places, so we don't need a global open. Furhtermore the String.t type is now inlined for Cabs to avoid shadowing problems in Elab.ml Bug 19872
* | Remove unused opens.Bernhard Schommer2017-02-031-32/+28
| | | | | | | | | | | | Format was only used in one place without explicit module prefix. The same holds for Env. Bug 19872
* | Removed no longer working check.Bernhard Schommer2017-02-031-14/+4
| | | | | | | | | | | | Since anonymous struct members are kept in the fieldlist, the fieldlist can never be empty in this case. Bug 19872
* | Updated handcrafted.messages for __builtin_offsetofBernhard Schommer2017-02-011-753/+858
| |
* | Change the syntax to gcc/clangs syntax.Bernhard Schommer2017-02-012-3/+6
| | | | | | | | | | | | This only means that there must be one identifier at the begining and then a designator. Bug 20765
* | Merge pull request #159 from AbsInt/builtin_offsetofXavier Leroy2017-02-017-2/+72
|\ \ | |/ |/| Implement offsetof via builtin
| * Avoid overflows and report an error.Bernhard Schommer2017-01-312-7/+10
| | | | | | | | | | | | | | Instead of multiplying the array constant directly with the size of the offset the cautious_mul function is used to detect potential overflows. Bug 20765
| * Normalize offset to size_t kind.Bernhard Schommer2017-01-311-2/+4
| |
| * Remove superfluous check.Bernhard Schommer2017-01-311-7/+4
| | | | | | | | | | | | Gcc and clang do not raise an error for this, also it should work for the last array element which can be without size. Bug 20765
| * Improve indentation.Bernhard Schommer2017-01-311-1/+1
| |
| * Remove blank lines.Bernhard Schommer2017-01-311-2/+0
| |
| * New version to support designators.Bernhard Schommer2017-01-247-21/+45
| | | | | | | | | | | | | | | | | | The c standard allows member designators for offsetof. The current implementation works by recursively combining the offset of each of the member designators. For array access the size of the subtypes is multiplied by the index and for members the offset of the member is calculated. Bug 20765
| * Simplified version.Bernhard Schommer2017-01-202-43/+26
| | | | | | | | | | | | | | | | The problem was that sub structs are were not correctly aligned. The new version is much simpler and uses the sizeof_struct to calculate the individual offsets and add them up to get correct offest. Bug 20765
| * Also support union. Bug 20765Bernhard Schommer2017-01-201-3/+4
| |
| * Implement offsetof via builtin.Bernhard Schommer2017-01-207-2/+64
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Typo in type of elab_char_constantXavier Leroy2017-01-311-1/+1
| | | | | | | | Follow-up to commit 1df1830
* | Export elab_{int,float,char}_constantXavier Leroy2017-01-311-0/+9
| | | | | | | | Those three functions can be useful to implement front-ends for languages other than C.
* | Added support for different diagnostic formats.Bernhard Schommer2017-01-301-2/+25
| | | | | | | | | | | | | | | | | | The new option -fdiagnostics-format allows it to switch between the three different format version: -ccomp (default) with file:line: -vi with file+line: -msvc with file(line): Bug 19872
* | Switch case for error option. Bug 19872Bernhard Schommer2017-01-301-2/+2
| |
* | Added -f(no-)diagnostics-show-option.Bernhard Schommer2017-01-271-6/+20
| | | | | | | | | | | | Controls whether the [-Woption] is printed in the diagnostic message for mappable warnings/errors. Bug 19872
* | Added option -fmax-errors.Bernhard Schommer2017-01-261-3/+14
| | | | | | | | | | | | | | The option -fmax-errors limits the number of errors that are reported before the compilation is aborted. The default 0 means no limit. Bug 19872
* | Added -w to disable all options. Bug 19872Bernhard Schommer2017-01-261-1/+6
|/
* Improve wording of normal backtrace case Bug 19872Bernhard Schommer2017-01-191-1/+3
|
* Use quoted strings.Bernhard Schommer2017-01-181-11/+12
| | | | | | Instead of escaping all newlines etc for the help options use quoted strings. Bug 19872
* More comments and improvements for unknown loc.Bernhard Schommer2017-01-182-1/+27
| | | | | | More functions are now documented. Furthermore compcert now prints "ccomp:" instead of nothing for unknown locations. Bug 19872
* Remove duplaceted relese. Bug 20681Bernhard Schommer2017-01-171-1/+1
|
* Added missing whitespace. Bug 19872Bernhard Schommer2017-01-171-1/+1
|
* Safe the backtrace earlier. Bug 20681Bernhard Schommer2017-01-171-12/+13
|
* Added backtrace handler.Bernhard Schommer2017-01-172-0/+19
| | | | | | | | If CompCert crashes because of an uncaught exception the exception is caught toplevel and the backtrace is printed plus an additional message to include the backtrace in a support request, if buildnr and tag are available. Bug 20681.
* Allow multiple nameless bit field fields.Bernhard Schommer2016-12-291-2/+4
|
* Merge pull request #153 from AbsInt/anonymous_struct2Bernhard Schommer2016-12-277-39/+113
|\ | | | | Next try for support of anonymous structs.
| * Avoid exception catch-allXavier Leroy2016-12-261-1/+1
| | | | | | | | "try ...; true with _ -> false" is dangerous if "..." raises unexpected exceptions such as Out_of_memory or Stack_overflow.
| * Cosmetic indentation changeXavier Leroy2016-12-261-5/+4
| |
| * Added code for initializers. Bug 20003Bernhard Schommer2016-12-121-1/+19
| |
| * Moved naming and changed names of aux functionsBernhard Schommer2016-12-121-16/+20
| | | | | | | | | | | | | | | | The naming of anonymous structs is performed by an additional step in elab_struct_or_union_info instead of in elab_field_group. Also the aux functions are renamed to access. Bug 20003
| * Next try for support of anonymous structs.Bernhard Schommer2016-12-077-41/+94
| | | | | | | | | | | | Instead of using idents the anonymous fileds get names of the for <anon>_c where c is a counter of all anonymous members. Bug 20003