aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Diagnostics.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2019-07-04 12:59:33 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2019-07-04 12:59:33 +0200
commitdebbae89f9faf47b95bd1c86058cd232783f3c3f (patch)
treec98aa4f51c5e80f5f01e74ffe07958d4632667f6 /cparser/Diagnostics.ml
parented2318e287c6edeeceed7e2a104195b08aa3e31a (diff)
downloadcompcert-kvx-debbae89f9faf47b95bd1c86058cd232783f3c3f.tar.gz
compcert-kvx-debbae89f9faf47b95bd1c86058cd232783f3c3f.zip
Added new diagnostic for non-linear conditionals
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.
Diffstat (limited to 'cparser/Diagnostics.ml')
-rw-r--r--cparser/Diagnostics.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/cparser/Diagnostics.ml b/cparser/Diagnostics.ml
index 51dcab47..012e4b66 100644
--- a/cparser/Diagnostics.ml
+++ b/cparser/Diagnostics.ml
@@ -102,6 +102,7 @@ type warning_type =
| Flexible_array_extensions
| Tentative_incomplete_static
| Reduced_alignment
+ | Non_linear_cond_expr
(* List of active warnings *)
let active_warnings: warning_type list ref = ref [
@@ -163,6 +164,7 @@ let string_of_warning = function
| Flexible_array_extensions -> "flexible-array-extensions"
| Tentative_incomplete_static -> "tentative-incomplete-static"
| Reduced_alignment -> "reduced-alignment"
+ | Non_linear_cond_expr -> "non-linear-cond-expr"
(* Activate the given warning *)
let activate_warning w () =
@@ -216,6 +218,7 @@ let wall () =
Flexible_array_extensions;
Tentative_incomplete_static;
Reduced_alignment;
+ Non_linear_cond_expr;
]
let wnothing () =
@@ -253,6 +256,7 @@ let werror () =
Flexible_array_extensions;
Tentative_incomplete_static;
Reduced_alignment;
+ Non_linear_cond_expr;
]
(* Generate the warning key for the message *)
@@ -437,6 +441,7 @@ let warning_options =
error_option Flexible_array_extensions @
error_option Tentative_incomplete_static @
error_option Reduced_alignment @
+ error_option Non_linear_cond_expr @
[Exact ("-Wfatal-errors"), Set error_fatal;
Exact ("-fdiagnostics-color"), Ignore; (* Either output supports it or no color *)
Exact ("-fno-diagnostics-color"), Unset color_diagnostics;
@@ -492,3 +497,6 @@ let crash exn =
let no_loc = ("", -1)
let file_loc file = (file,-10)
+
+let active_warning ty =
+ fst (classify_warning ty) <> SuppressedMsg