浏览代码

Fix for Mantis #28832

ninl.pas, tinlinenode:
  * pass_typecheck: let code pass on to simplify() for undefineddefs in Low() and High()
  * simplify: create a constant 0 as fallback

+ added test

git-svn-id: trunk@33884 -
svenbarth 9 年之前
父节点
当前提交
8c96fbed8f
共有 3 个文件被更改,包括 24 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/ninl.pas
  3. 18 0
      tests/webtbs/tw28832.pp

+ 1 - 0
.gitattributes

@@ -15023,6 +15023,7 @@ tests/webtbs/tw2876.pp svneol=native#text/plain
 tests/webtbs/tw28766.pp svneol=native#text/pascal
 tests/webtbs/tw28801.pp svneol=native#text/plain
 tests/webtbs/tw2883.pp svneol=native#text/plain
+tests/webtbs/tw28832.pp svneol=native#text/pascal
 tests/webtbs/tw2885.pp svneol=native#text/plain
 tests/webtbs/tw28850.pp svneol=native#text/plain
 tests/webtbs/tw2886.pp svneol=native#text/plain

+ 5 - 0
compiler/ninl.pas

@@ -2337,6 +2337,10 @@ implementation
                         else if not is_dynamicstring(left.resultdef) then
                           result:=cordconstnode.create(tstringdef(left.resultdef).len,u8inttype,true)
                       end;
+                    undefineddef:
+                      begin
+                        result:=cordconstnode.create(0,u8inttype,false);
+                      end;
                   end;
                 end;
               in_exp_real :
@@ -3045,6 +3049,7 @@ implementation
               in_high_x:
                 begin
                   case left.resultdef.typ of
+                    undefineddef,
                     orddef,
                     enumdef,
                     setdef:

+ 18 - 0
tests/webtbs/tw28832.pp

@@ -0,0 +1,18 @@
+{ %NORUN }
+
+program tw28832;
+
+{$mode objfpc}{$H+}
+
+generic procedure Test<T>(AValue : T);
+begin
+  WriteLn(Low(AValue));
+  WriteLn(Low(T));
+  WriteLn(High(AValue));
+  WriteLn(High(T));
+end;
+
+begin
+  specialize Test<Integer>(0);
+end.
+