浏览代码

* fixed some issue with the inputpointer when specializing generics

git-svn-id: trunk@5122 -
florian 19 年之前
父节点
当前提交
5cb1af6e2a
共有 3 个文件被更改,包括 27 次插入3 次删除
  1. 1 0
      .gitattributes
  2. 7 3
      compiler/scanner.pas
  3. 19 0
      tests/webtbs/tw7422.pp

+ 1 - 0
.gitattributes

@@ -7566,6 +7566,7 @@ tests/webtbs/tw7329.pp svneol=native#text/plain
 tests/webtbs/tw7372.pp svneol=native#text/plain
 tests/webtbs/tw7379.pp svneol=native#text/plain
 tests/webtbs/tw7391.pp svneol=native#text/plain
+tests/webtbs/tw7422.pp svneol=native#text/plain
 tests/webtbs/tw7425.pp svneol=native#text/plain
 tests/webtbs/tw7440.pp svneol=native#text/plain
 tests/webtbs/tw7446.pp svneol=native#text/plain

+ 7 - 3
compiler/scanner.pas

@@ -1916,7 +1916,8 @@ In case not, the value returned can be arbitrary.
         if token in [_CWCHAR,_CWSTRING,_CCHAR,_CSTRING,_INTCONST,_REALNUMBER,_ID] then
           internalerror(200511178);
         replaysavetoken:=token;
-        dec(inputpointer);
+        if assigned(inputpointer) then
+          dec(inputpointer);
         { install buffer }
         replaytokenbuf:=buf;
 
@@ -1937,8 +1938,11 @@ In case not, the value returned can be arbitrary.
         if replaytokenbuf.pos>=replaytokenbuf.size then
           begin
             replaytokenbuf:=nil;
-            c:=inputpointer^;
-            inc(inputpointer);
+            if assigned(inputpointer) then
+              begin
+                c:=inputpointer^;
+                inc(inputpointer);
+              end;
             token:=replaysavetoken;
             exit;
           end;

+ 19 - 0
tests/webtbs/tw7422.pp

@@ -0,0 +1,19 @@
+{$mode objfpc}
+type generic PListNode<_T> = ^specialize TListNode;
+     generic TListNode<_T> = class(TObject)
+         Data: _T;
+         Next,Prev: PListNode;
+     end;
+     generic TList<_T> = class(TObject)
+         First,Last: PListNode;
+         procedure add(item: _T);
+     end;
+
+procedure TList.add(item: _T);
+begin
+end;
+
+type TMyList = specialize TList<real>;
+
+begin
+end.