aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Checks.ml
Commit message (Collapse)AuthorAgeFilesLines
* [BROKEN] Merge with v3.9 : something broken for __builtin_expect in ↵Cyril SIX2021-06-011-4/+5
| | | | cfrontend/C2C.ml
* Remove the cparser/Builtins moduleXavier Leroy2019-07-171-1/+1
| | | | | | | | | Move its definitions to modules C (the type `builtins`) and Env (the operations that deal with the initial environment). Reasons for the refactoring: 1- The name "Builtins" will soon be reused for a Coq module 2- `Env.initial()` makes more sense than `Builtins.environment()`.
* Change condition for warning of conditional exprBernhard Schommer2019-07-101-1/+1
| | | | | | The warning should only be active if the optimization is active, so the check is only performed when the warning is active and additionally the command line flag -Obranchless is specified.
* Deref is not safe.Bernhard Schommer2019-07-041-1/+1
|
* Added new diagnostic for non-linear conditionalsBernhard Schommer2019-07-041-0/+163
| | | | | | | | | | | | | | The new diagnostics is triggered if a conditional is used that may not be transformed into linear code by the later by the if conversion. The new diagnostic is emitted if a conditional may contain an unsafe expression or is contained within another conditional, logical and or logical or expression. An expression is unsafe if it contains a call, changes memory or if its evaluation leads to undefined behavior, for example division and modulo. Also fixes a small typo in a comment in Cutil.
* Added statement traversal functions.Bernhard Schommer2019-07-041-107/+90
| | | | | | Refactored the checks functions by using higher order traversal functions for statements. Also introduce helper functions for the traversal of initializers.
* Reject object-related and struct-related attributes on typedefsXavier Leroy2019-02-251-8/+1
| | | | | | | | | | | | | | | | | | | | This commit adds a check to reject type definitions such as ``` typedef __attribute((section "foo")) int fooint; ``` GCC and Clang also reject this as an error. Without the check, the behavior is somewhat surprising: ``` fooint x; // placed in section "foo" fooint * x; // placed in default section, attribute "foo" is ignored ``` Note that the following must be accepted: ``` typedef struct { ... } __attribute((packed)) t; ``` The "packed" attribute is correctly attached to the struct type and should not be checked. This is achieved by using `attribute_of_type_no_expand` to get the attributes of the typedef-ed type, excluding the attributes carried by a struct/union or another typedef.
* Also check parameters for unknown attributes.Bernhard Schommer2018-08-161-0/+1
| | | | | | Parameters also need to be checkd for unknown attributes, like all other declarations. Bug 24277
* Refactor the handling of errors and warnings (#44)Bernhard Schommer2018-02-081-1/+1
| | | | | | | | | | | | | | | | | * Module Cerrors is now called Diagnostic and can be used in parts of CompCert other than cparser/ * Replaced eprintf error. Instead of having eprintf msg; exit 2 use the functions from the Diagnostics module. * Raise on error before calling external tools. * Added diagnostics to clightgen. * Fix error handling of AsmToJson. * Cleanup error handling of Elab and C2C. *The implementation of location printing (file & line) is simplified and correctly prints valid filenames with invalid lines.
* Added unused attribute and simplified checks.Bernhard Schommer2017-02-171-43/+82
| | | | | | | | | The attribute unused can be used to indicate if a variable or parameter is unused and no warning should be emitted for it. Furthermore this commit simplifies the check by adding a generic function to traverse the program. Bug 19872
* Adopted unused variable and attribtue checkBernhard Schommer2017-02-171-28/+53
| | | | | | | | | The unused variable check now uses two passes. One to collect the used variables and one to report the unused variables. Futhermore attribute checks are extended to composite declaration. Also the check is now performed after elaboration. Bug 19872
* Extended unused vars check for params.Bernhard Schommer2017-02-171-1/+3
| | | | | | The test now also checks whether the parameter are used at all in the function body. Bug 19872
* Added a simple check for unused variables.Bernhard Schommer2017-02-171-1/+77
| | | | | | | | | | | | | | | | | The check test whether the identifier is used at all in the function and if not issue a warning. It is not tested whether the usage is reachable at all, so int i; if (0) i; would not generate a warning. This is the same as gcc/clang does. The warning is disabled per default, but is active if -Wall is given. Bug 19872
* Checks can be applied add several places.Bernhard Schommer2017-02-171-6/+3
| | | | | | There should not be a single check place, since for example unknonw attributes should be check after elaboration and other simplifications.
* Also check the locals. Bug 19872.Bernhard Schommer2017-02-171-3/+7
|
* Added new module for checks on elaborated C codeBernhard Schommer2017-02-171-0/+94
The new module adds a function which is called during parse after all C transformation have taken place for adding additional checks. Currently only unknown attribute are checked. Bug 19872