From cdeece5cb3f3087baa641c41cc30ec34aa635edd Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 19 Apr 2018 08:49:18 +0200 Subject: 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 --- cfrontend/C2C.ml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cfrontend') 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| -- cgit