diff options
author | Bernhard Schommer <bschommer@users.noreply.github.com> | 2018-04-19 08:49:18 +0200 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2018-04-19 09:49:18 +0300 |
commit | cdeece5cb3f3087baa641c41cc30ec34aa635edd (patch) | |
tree | 9d507df76f9bf861d073ea0dc843be361eeadcf0 /cfrontend/C2C.ml | |
parent | e79bc7f63db91866c2401c898cffe373125d46c6 (diff) | |
download | compcert-cdeece5cb3f3087baa641c41cc30ec34aa635edd.tar.gz compcert-cdeece5cb3f3087baa641c41cc30ec34aa635edd.zip |
Warn when volatile struct is assigned to a normal struct
Adds a warning when a volatile struct is assigned to another
struct, that the volatile qualifier is ignored in this context.
Example:
```
volatile struct S s;
struct S t;
t = s; // did not warn before; now it warns
s = t; // did warn already
```
Bug 23489
Diffstat (limited to 'cfrontend/C2C.ml')
-rw-r--r-- | cfrontend/C2C.ml | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml index c4772688..e9a3ea92 100644 --- a/cfrontend/C2C.ml +++ b/cfrontend/C2C.ml @@ -793,6 +793,9 @@ let rec convertExpr env e = if Cutil.is_composite_type env e1.etyp && List.mem AVolatile (Cutil.attributes_of_type env e1.etyp) then warning Diagnostics.Unnamed "assignment to an lvalue of volatile composite type, the 'volatile' qualifier is ignored"; + if Cutil.is_composite_type env e2.etyp + && List.mem AVolatile (Cutil.attributes_of_type env e2.etyp) then + warning Diagnostics.Unnamed "assignment of a value of volatile composite type, the 'volatile' qualifier is ignored"; ewrap (Ctyping.eassign e1' e2') | C.EBinop((C.Oadd_assign|C.Osub_assign|C.Omul_assign|C.Odiv_assign| C.Omod_assign|C.Oand_assign|C.Oor_assign|C.Oxor_assign| |