diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-02-09 11:07:06 +0100 |
---|---|---|
committer | Bernhard Schommer <bschommer@users.noreply.github.com> | 2017-02-17 14:09:56 +0100 |
commit | 201ca60922ede81a0861e76f9399fc400fafb440 (patch) | |
tree | 31abf21e14e9d68a58d3d51974e31ae66b505a52 /cparser/Elab.ml | |
parent | f066675dc9ead0ef88e27c139c046906f2fcdaeb (diff) | |
download | compcert-201ca60922ede81a0861e76f9399fc400fafb440.tar.gz compcert-201ca60922ede81a0861e76f9399fc400fafb440.zip |
Added a simple check for unused variables.
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
Diffstat (limited to 'cparser/Elab.ml')
-rw-r--r-- | cparser/Elab.ml | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 02980529..d75e2410 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -2673,4 +2673,6 @@ let _ = elab_funbody_f := elab_funbody let elab_file prog = reset(); ignore (elab_definitions false (Builtins.environment()) prog); - elaborated_program() + let p = elaborated_program () in + Checks.unused_variables p; + p |