aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2018-04-23 10:47:10 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-04-27 13:54:38 +0200
commit6f5eec9f5f1ad4567186172a4519e598af801b94 (patch)
treecf7a8249630fc2d130939c076598eef482851f7e /cfrontend
parent2f9932b8c5ff116d417c1e5197cd8e51f8d59b5e (diff)
downloadcompcert-kvx-6f5eec9f5f1ad4567186172a4519e598af801b94.tar.gz
compcert-kvx-6f5eec9f5f1ad4567186172a4519e598af801b94.zip
Record value of constant expression in C.Scase constructor
The Elab pass checks that the argument of 'case' is a compile-time constant expression. This commit records the value of this expression in the C.Scase AST generated by Elab, so that it can be used for further diagnostics, i.e. checking (in Elab) for duplicate cases. Note that C2C ignores the recorded value and recomputes the value of the expression using Ceval.integer_expr. This is intentional: Ceval.integer_expr is more trustworthy, as it is formally verified against the CompCert C semantics.
Diffstat (limited to 'cfrontend')
-rw-r--r--cfrontend/C2C.ml2
1 files changed, 1 insertions, 1 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml
index e9a3ea92..5777eb96 100644
--- a/cfrontend/C2C.ml
+++ b/cfrontend/C2C.ml
@@ -1005,7 +1005,7 @@ type switchbody =
let rec flattenSwitch = function
| {sdesc = C.Sseq(s1, s2)} ->
flattenSwitch s1 @ flattenSwitch s2
- | {sdesc = C.Slabeled(C.Scase e, s1)} ->
+ | {sdesc = C.Slabeled(C.Scase(e, _), s1)} ->
Label(Case e) :: flattenSwitch s1
| {sdesc = C.Slabeled(C.Sdefault, s1)} ->
Label Default :: flattenSwitch s1