diff options
author | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2013-05-14 12:05:00 +0000 |
---|---|---|
committer | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2013-05-14 12:05:00 +0000 |
commit | 217da726fe08e160ad63abe4b3bb53f3f436c966 (patch) | |
tree | bc58f4e53acb5e16c5e3f15f186eef7ed78bb221 /compiler/ngtcon.pas | |
parent | 73b9215814d738c19780097ab909539ac57ba340 (diff) | |
download | fpc-217da726fe08e160ad63abe4b3bb53f3f436c966.tar.gz |
* check range of enums and booleans in typed constant expressions when
using the asmlist generator (mantis #24428)
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@24495 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/ngtcon.pas')
-rw-r--r-- | compiler/ngtcon.pas | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler/ngtcon.pas b/compiler/ngtcon.pas index c6001a6bcd..b116b8ca78 100644 --- a/compiler/ngtcon.pas +++ b/compiler/ngtcon.pas @@ -602,7 +602,10 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis bool8bit : begin if is_constboolnode(node) then - list.concat(Tai_const.Create_8bit(byte(tordconstnode(node).value.svalue))) + begin + testrange(def,tordconstnode(node).value,false,false); + list.concat(Tai_const.Create_8bit(byte(tordconstnode(node).value.svalue))) + end else do_error; end; @@ -610,7 +613,10 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis bool16bit : begin if is_constboolnode(node) then - list.concat(Tai_const.Create_16bit(word(tordconstnode(node).value.svalue))) + begin + testrange(def,tordconstnode(node).value,false,false); + list.concat(Tai_const.Create_16bit(word(tordconstnode(node).value.svalue))) + end else do_error; end; @@ -618,7 +624,10 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis bool32bit : begin if is_constboolnode(node) then - list.concat(Tai_const.Create_32bit(longint(tordconstnode(node).value.svalue))) + begin + testrange(def,tordconstnode(node).value,false,false); + list.concat(Tai_const.Create_32bit(longint(tordconstnode(node).value.svalue))) + end else do_error; end; @@ -626,7 +635,10 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis bool64bit : begin if is_constboolnode(node) then - list.concat(Tai_const.Create_64bit(int64(tordconstnode(node).value.svalue))) + begin + testrange(def,tordconstnode(node).value,false,false); + list.concat(Tai_const.Create_64bit(int64(tordconstnode(node).value.svalue))) + end else do_error; end; @@ -1019,6 +1031,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis if equal_defs(node.resultdef,def) or is_subequal(node.resultdef,def) then begin + testrange(def,tordconstnode(node).value,false,false); case longint(node.resultdef.size) of 1 : list.concat(Tai_const.Create_8bit(Byte(tordconstnode(node).value.svalue))); 2 : list.concat(Tai_const.Create_16bit(Word(tordconstnode(node).value.svalue))); |