浏览代码

* check range of enums and booleans in typed constant expressions when
using the asmlist generator (mantis #24428)

git-svn-id: trunk@24495 -

Jonas Maebe 12 年之前
父节点
当前提交
11d5d4f79d
共有 4 个文件被更改,包括 35 次插入4 次删除
  1. 2 0
      .gitattributes
  2. 17 4
      compiler/ngtcon.pas
  3. 8 0
      tests/webtbf/tw24428.pp
  4. 8 0
      tests/webtbf/tw24428a.pp

+ 2 - 0
.gitattributes

@@ -12321,6 +12321,8 @@ tests/webtbf/tw24013b.pp svneol=native#text/plain
 tests/webtbf/tw2403.pp svneol=native#text/plain
 tests/webtbf/tw2414.pp svneol=native#text/plain
 tests/webtbf/tw24184.pp svneol=native#text/plain
+tests/webtbf/tw24428.pp svneol=native#text/plain
+tests/webtbf/tw24428a.pp svneol=native#text/plain
 tests/webtbf/tw2478.pp svneol=native#text/plain
 tests/webtbf/tw2562.pp svneol=native#text/plain
 tests/webtbf/tw2657.pp svneol=native#text/plain

+ 17 - 4
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)));

+ 8 - 0
tests/webtbf/tw24428.pp

@@ -0,0 +1,8 @@
+{ %fail }
+
+{$r+}
+
+type abcd = (a, b, c, d);
+const cd: c..d = a;
+begin
+end.

+ 8 - 0
tests/webtbf/tw24428a.pp

@@ -0,0 +1,8 @@
+{ %fail }
+
+{$r+}
+
+type tt = True..True;
+const t: tt = False;
+begin
+end.