Selaa lähdekoodia

* support constset in $if

git-svn-id: trunk@538 -
peter 20 vuotta sitten
vanhempi
commit
408bba521a
5 muutettua tiedostoa jossa 39 lisäystä ja 4 poistoa
  1. 1 0
      .gitattributes
  2. 3 0
      compiler/globtype.pas
  3. 0 3
      compiler/node.pas
  4. 11 1
      compiler/scanner.pas
  5. 24 0
      tests/webtbf/tw4139.pp

+ 1 - 0
.gitattributes

@@ -5467,6 +5467,7 @@ tests/webtbf/tw3740.pp svneol=native#text/plain
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3841.pp svneol=native#text/plain
 tests/webtbf/tw4111.pp svneol=native#text/plain
+tests/webtbf/tw4139.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

+ 3 - 0
compiler/globtype.pas

@@ -76,6 +76,9 @@ than 255 characters. That's why using Ansi Strings}
        tdoublearray = array[0..7] of byte;
        textendedarray = array[0..9] of byte;
 
+       pconstset = ^tconstset;
+       tconstset = set of 0..255;
+
        { Switches which can be changed locally }
        tlocalswitch = (cs_localnone,
          { codegen }

+ 0 - 3
compiler/node.pas

@@ -33,9 +33,6 @@ interface
        symtype;
 
     type
-       pconstset = ^tconstset;
-       tconstset = set of 0..255;
-
        tnodetype = (
           emptynode,        {No node (returns nil when loading from ppu)}
           addn,             {Represents the + operator}

+ 11 - 1
compiler/scanner.pas

@@ -670,7 +670,17 @@ implementation
                                           end;
                                         end;
                                       conststring :
-                                        read_factor := upper(pchar(value.valueptr))
+                                        read_factor := upper(pchar(value.valueptr));
+                                      constset :
+                                        begin
+                                          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+',';
+                                          read_factor := hs;
+                                        end;
                                     end;
                                   end;
                               end;

+ 24 - 0
tests/webtbf/tw4139.pp

@@ -0,0 +1,24 @@
+{ %fail }
+{ %opt=-Sew }
+
+{ Source provided for Free Pascal Bug Report 4139 }
+{ Submitted by "Christian Iversen" on  2005-06-29 }
+{ e-mail: [email protected] }
+
+{$mode delphi}
+
+type
+  Foobar = (a, b, c, d);
+
+const
+  Test = c;
+
+const
+  List = [a, c];
+
+{$IF Test in List}
+  {$MESSAGE WARN 'This should work'}
+{$IFEND}
+
+begin
+end.