Browse Source

* fix type checking in constant sets

git-svn-id: trunk@583 -
peter 20 years ago
parent
commit
bead787962
3 changed files with 29 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 5 2
      compiler/ncnv.pas
  3. 23 0
      tests/webtbf/tw4153.pp

+ 1 - 0
.gitattributes

@@ -5487,6 +5487,7 @@ tests/webtbf/tw4103.pp svneol=native#text/plain
 tests/webtbf/tw4111.pp svneol=native#text/plain
 tests/webtbf/tw4111.pp svneol=native#text/plain
 tests/webtbf/tw4139.pp svneol=native#text/plain
 tests/webtbf/tw4139.pp svneol=native#text/plain
 tests/webtbf/tw4144.pp svneol=native#text/plain
 tests/webtbf/tw4144.pp svneol=native#text/plain
+tests/webtbf/tw4153.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain

+ 5 - 2
compiler/ncnv.pas

@@ -442,8 +442,11 @@ implementation
                                       htype:=p2.resulttype;
                                       htype:=p2.resulttype;
                                   end
                                   end
                                 else
                                 else
-                                  update_constsethi(p2.resulttype)
-                              end
+                                  update_constsethi(p2.resulttype);
+                              end;
+
+                            if assigned(htype.def) then
+                              inserttypeconv(p2,htype)
                             else
                             else
                               inserttypeconv(p2,u8inttype);
                               inserttypeconv(p2,u8inttype);
 
 

+ 23 - 0
tests/webtbf/tw4153.pp

@@ -0,0 +1,23 @@
+{ %fail }
+
+{ Source provided for Free Pascal Bug Report 4153 }
+{ Submitted by "Ivo Steinmann" on  2005-07-03 }
+{ e-mail: [email protected] }
+type
+  Enum1 = (a, b, c);
+  Enum2 = (x, y, z);
+
+const
+  // The next line should fail
+  Foobar = [b, z];
+
+begin
+  if a in Foobar then
+    WriteLn('a in Foobar'); // not printed
+
+  if b in Foobar then
+    WriteLn('b in Foobar'); // printed
+
+  if c in Foobar then
+    WriteLn('c in Foobar'); // printed
+end.