Fix assignment to/from volatile types

Code like this was broken:

   char volatile vi = i;

See testcase, happens in ideosyncratic legacy code sprinkling
volatile all over.
This commit is contained in:
Michael Matz
2016-03-26 17:57:22 +01:00
parent 8fc5a6a2a4
commit 80343ab7d8
3 changed files with 17 additions and 0 deletions

View File

@ -369,6 +369,8 @@ void load(int r, SValue *sv)
ft = sv->type.t & ~VT_DEFSIGN;
fc = sv->c.i;
ft &= ~(VT_VOLATILE | VT_CONSTANT);
#ifndef TCC_TARGET_PE
/* we use indirect access via got */
if ((fr & VT_VALMASK) == VT_CONST && (fr & VT_SYM) &&
@ -532,6 +534,7 @@ void store(int r, SValue *v)
ft = v->type.t;
fc = v->c.i;
fr = v->r & VT_VALMASK;
ft &= ~(VT_VOLATILE | VT_CONSTANT);
bt = ft & VT_BTYPE;
#ifndef TCC_TARGET_PE