Browse Source

* fix preprocessor support for empty set constants

git-svn-id: trunk@584 -
peter 20 years ago
parent
commit
4222e24422
3 changed files with 16 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 2 4
      compiler/scanner.pas
  3. 13 0
      tests/webtbs/tw4151.pp

+ 1 - 0
.gitattributes

@@ -6132,6 +6132,7 @@ tests/webtbs/tw4115.pp svneol=native#text/plain
 tests/webtbs/tw4119.pp svneol=native#text/plain
 tests/webtbs/tw4140.pp svneol=native#text/plain
 tests/webtbs/tw4150.pp svneol=native#text/plain
+tests/webtbs/tw4151.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 2 - 4
compiler/scanner.pas

@@ -689,12 +689,10 @@ implementation
                                         read_factor := upper(pchar(value.valueptr));
                                       constset :
                                         begin
-                                          hs:='';
+                                          hs:=',';
                                           for l:=0 to 255 do
                                             if l in pconstset(tconstsym(srsym).value.valueptr)^ then
-                                              hs:=hs+','+tostr(l);
-                                          if hs<>'' then
-                                            hs:=hs+',';
+                                              hs:=hs+tostr(l)+',';
                                           read_factor := hs;
                                         end;
                                     end;

+ 13 - 0
tests/webtbs/tw4151.pp

@@ -0,0 +1,13 @@
+{ Source provided for Free Pascal Bug Report 4151 }
+{ Submitted by "Christian Iversen" on  2005-07-03 }
+{ e-mail: [email protected] }
+program foo;
+type
+  t = (a, b, c);
+const bar = [];
+
+{$IF a in bar}{$MESSAGE ERROR '1'}{$IFEND}
+{$IF a in []}{$MESSAGE ERROR '2'}{$IFEND}
+
+begin
+end.