aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i386-gen.c3
-rw-r--r--tests/tcctest.c11
-rw-r--r--x86_64-gen.c3
3 files changed, 17 insertions, 0 deletions
diff --git a/i386-gen.c b/i386-gen.c
index c18b9c3..fc0748f 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -223,6 +223,8 @@ ST_FUNC void load(int r, SValue *sv)
ft = sv->type.t;
fc = sv->c.i;
+ ft &= ~(VT_VOLATILE | VT_CONSTANT);
+
v = fr & VT_VALMASK;
if (fr & VT_LVAL) {
if (v == VT_LLOCAL) {
@@ -298,6 +300,7 @@ ST_FUNC 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;
/* XXX: incorrect if float reg to reg */
if (bt == VT_FLOAT) {
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 381a992..823a657 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -119,6 +119,8 @@ int isid(int c);
void funny_line_continuation (int, ..\
. );
+char via_volatile (char);
+
#define A 2
#define N 1234 + A
#define pf printf
@@ -693,6 +695,8 @@ int main(int argc, char **argv)
callsave_test();
builtin_frame_address_test();
intdiv_test();
+ if (via_volatile (42) != 42)
+ printf ("via_volatile broken\n");
return 0;
}
@@ -2848,3 +2852,10 @@ void builtin_frame_address_test(void)
bfa1(str-fp0);
#endif
}
+
+char via_volatile (char i)
+{
+ char volatile vi;
+ vi = i;
+ return vi;
+}
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 692b420..bf983d4 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -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