浏览代码

Record variant discriminators: check types

Jonas Maebe 3 年之前
父节点
当前提交
15865e7602
共有 2 个文件被更改,包括 11 次插入0 次删除
  1. 1 0
      compiler/pdecvar.pas
  2. 10 0
      tests/tbf/tb0276.pp

+ 1 - 0
compiler/pdecvar.pas

@@ -1940,6 +1940,7 @@ implementation
                   pt:=comp_expr([ef_accept_equal]);
                   pt:=comp_expr([ef_accept_equal]);
                   if not(pt.nodetype=ordconstn) then
                   if not(pt.nodetype=ordconstn) then
                     Message(parser_e_illegal_expression);
                     Message(parser_e_illegal_expression);
+                  inserttypeconv(pt,casetype);
                   { iso pascal does not support ranges in variant record definitions }
                   { iso pascal does not support ranges in variant record definitions }
                   if (([m_iso,m_extpas]*current_settings.modeswitches)=[]) and try_to_consume(_POINTPOINT) then
                   if (([m_iso,m_extpas]*current_settings.modeswitches)=[]) and try_to_consume(_POINTPOINT) then
                     pt:=crangenode.create(pt,comp_expr([ef_accept_equal]))
                     pt:=crangenode.create(pt,comp_expr([ef_accept_equal]))

+ 10 - 0
tests/tbf/tb0276.pp

@@ -0,0 +1,10 @@
+{ %fail }
+
+type
+  trec = record
+    case boolean of
+      1: (b: byte);
+  end;
+
+begin
+end.