浏览代码

* handle records in iso mode properly if no tag-field is given

git-svn-id: trunk@29259 -
florian 10 年之前
父节点
当前提交
dd967eb136
共有 3 个文件被更改,包括 31 次插入5 次删除
  1. 1 0
      .gitattributes
  2. 7 5
      compiler/pinline.pas
  3. 23 0
      tests/test/tisorec4.pp

+ 1 - 0
.gitattributes

@@ -11801,6 +11801,7 @@ tests/test/tisoread.pp svneol=native#text/pascal
 tests/test/tisorec1.pp svneol=native#text/pascal
 tests/test/tisorec2.pp svneol=native#text/pascal
 tests/test/tisorec3.pp svneol=native#text/pascal
+tests/test/tisorec4.pp svneol=native#text/pascal
 tests/test/tlea1.pp svneol=native#text/plain
 tests/test/tlea2.pp svneol=native#text/plain
 tests/test/tlib1a.pp svneol=native#text/plain

+ 7 - 5
compiler/pinline.pas

@@ -376,11 +376,13 @@ implementation
                                    end;
                                  if found then
                                    begin
-                                     { setup variant selector }
-                                     addstatement(newstatement,cassignmentnode.create(
-                                         csubscriptnode.create(variantselectsymbol,
-                                           cderefnode.create(ctemprefnode.create(temp))),
-                                         p2));
+                                     { if no tag-field is given, do not create an assignment statement for it }
+                                     if assigned(variantselectsymbol) then
+                                       { setup variant selector }
+                                       addstatement(newstatement,cassignmentnode.create(
+                                           csubscriptnode.create(variantselectsymbol,
+                                             cderefnode.create(ctemprefnode.create(temp))),
+                                           p2));
                                    end
                                  else
                                    Message(parser_e_illegal_expression);

+ 23 - 0
tests/test/tisorec4.pp

@@ -0,0 +1,23 @@
+{$mode iso}
+type
+  tr = record
+    l : longint;
+    case integer of
+      1 : (s : array[0..255] of char);
+      2 : (n : integer);
+      3 : (w : word; case j : integer of
+        1 : (t : array[0..255] of char);
+        2 : (a : integer);
+        );
+  end;
+  pr = ^tr;
+
+var
+  r : pr;
+begin
+  new(r,3,2);
+  if r^.j<>2 then
+    halt(1);
+  dispose(r);
+  writeln('ok');
+end.