Browse Source

Merged revisions 6885,6892 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r6885 | jonas | 2007-03-16 20:44:43 +0100 (Fri, 16 Mar 2007) | 3 lines

* give again an error for "in" operations on incompatible set
elements/sets after introduction of support for "longint in set"

........
r6892 | jonas | 2007-03-16 23:31:51 +0100 (Fri, 16 Mar 2007) | 2 lines

* slightly improved previous in checking patch

........

git-svn-id: branches/fixes_2_2@6916 -

Jonas Maebe 18 years ago
parent
commit
7284888d38
3 changed files with 28 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 11 1
      compiler/nset.pas
  3. 16 0
      tests/webtbf/tw8528.pp

+ 1 - 0
.gitattributes

@@ -7191,6 +7191,7 @@ tests/webtbf/tw8150f.pp svneol=native#text/plain
 tests/webtbf/tw8150g.pp svneol=native#text/plain
 tests/webtbf/tw8264a.pp svneol=native#text/plain
 tests/webtbf/tw8398.pp svneol=native#text/plain
+tests/webtbf/tw8528.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain

+ 11 - 1
compiler/nset.pas

@@ -268,7 +268,17 @@ implementation
                inserttypeconv(left,s32inttype)
              else
                inserttypeconv(left,u32inttype);
-           end;
+           end
+         else if assigned(tsetdef(right.resultdef).elementdef) and
+                 not(is_integer(tsetdef(right.resultdef).elementdef) and
+                     is_integer(left.resultdef)) then
+            { Type conversion to check things like 'char in set_of_byte'. }
+            { Can't use is_subequal because that will fail for            }
+            { 'widechar in set_of_char'                                   }
+            { Can't use the type conversion for integers because then     }
+            { "longint in set_of_byte" will give a range check error      }
+            { instead of false                                            }
+            inserttypeconv(left,tsetdef(right.resultdef).elementdef);
 
          { empty set then return false }
          if not assigned(tsetdef(right.resultdef).elementdef) or

+ 16 - 0
tests/webtbf/tw8528.pp

@@ -0,0 +1,16 @@
+{ %fail }
+
+program test;
+
+{$mode objfpc}{$H+}
+
+const
+  AllowedCharSet: set of Byte = [48..60];
+
+var
+  s: string;
+begin
+  s := 'test0';
+  if s[5] in AllowedCharSet then
+    Writeln('huh?');
+end.