浏览代码

* only consider tc_pointer_to_array typeconversions to determine whether a
pointer->array type conversion implies an implicit dereference operation
(mantis #25622)

git-svn-id: trunk@26608 -

Jonas Maebe 11 年之前
父节点
当前提交
89d97a3c2e
共有 4 个文件被更改,包括 50 次插入2 次删除
  1. 2 0
      .gitattributes
  2. 2 2
      compiler/htypechk.pas
  3. 23 0
      tests/webtbf/tw25622.pp
  4. 23 0
      tests/webtbf/tw25622a.pp

+ 2 - 0
.gitattributes

@@ -12637,6 +12637,8 @@ tests/webtbf/tw25215.pp svneol=native#text/pascal
 tests/webtbf/tw25318.pp svneol=native#text/pascal
 tests/webtbf/tw25504.pp svneol=native#text/plain
 tests/webtbf/tw2562.pp svneol=native#text/plain
+tests/webtbf/tw25622.pp svneol=native#text/plain
+tests/webtbf/tw25622a.pp svneol=native#text/plain
 tests/webtbf/tw2657.pp svneol=native#text/plain
 tests/webtbf/tw2670.pp svneol=native#text/plain
 tests/webtbf/tw2719.pp svneol=native#text/plain

+ 2 - 2
compiler/htypechk.pas

@@ -1512,8 +1512,8 @@ implementation
                      begin
                        { pointer -> array conversion is done then we need to see it
                          as a deref, because a ^ is then not required anymore }
-                       if (ttypeconvnode(hp).left.resultdef.typ=pointerdef) then
-                        gotderef:=true;
+                       if ttypeconvnode(hp).convtype=tc_pointer_2_array then
+                         gotderef:=true;
                      end;
                  end;
                  hp:=ttypeconvnode(hp).left;

+ 23 - 0
tests/webtbf/tw25622.pp

@@ -0,0 +1,23 @@
+{ %fail }
+
+{$mode delphi}
+
+program test;
+
+type
+   TDynamicArray = array of record end; // or array of whatever
+   PDynamicArray = ^TDynamicArray;
+
+function TestA(): Pointer;
+begin
+   Result := nil;
+end;
+
+function TestB(): PDynamicArray;
+begin
+   // can't take address of function return value, but compiler instead says "Internal error 2006111510"
+   Result := @TDynamicArray(TestA());
+end;
+
+begin
+end.

+ 23 - 0
tests/webtbf/tw25622a.pp

@@ -0,0 +1,23 @@
+{ %fail }
+
+{$mode delphi}
+
+program test;
+
+type
+   PArray = ^TArray;
+   TArray = array[1..sizeof(ptrint)] of byte;
+
+function TestA(): Pointer;
+begin
+   Result := nil;
+end;
+
+function TestB(): PArray;
+begin
+   // can't take address of function return value, but compiler instead says "Internal error 2006111510"
+   Result := @TArray(TestA());
+end;
+
+begin
+end.