View Issue Details

IDProjectCategoryView StatusLast Update
0031692FPCFCLpublic2017-04-22 11:57
ReporterAndrey ZubarevAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product VersionProduct Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0031692: fcl-passrc manage creation default compiler defs for ParseSource function [patch]
DescriptionAdd CreateDefaultDefs:Boolean=true param to ParseSource function
TagsNo tags attached.
Fixed in Revision35889
FPCOldBugId
FPCTarget
Attached Files
  • pparser_ParseSource_CreateDefaultDefs.pp.patch (3,802 bytes)
    Index: packages/fcl-passrc/src/pparser.pp
    ===================================================================
    --- packages/fcl-passrc/src/pparser.pp	(revision 35878)
    +++ packages/fcl-passrc/src/pparser.pp	(working copy)
    @@ -402,7 +402,8 @@
     
     function ParseSource(AEngine: TPasTreeContainer;
                          const FPCCommandLine, OSTarget, CPUTarget: String;
    -                     UseStreams  : Boolean = False): TPasModule;
    +                     UseStreams  : Boolean = False;
    +                     CreateDefaultDefs  : Boolean = true): TPasModule;
     Function IsHintToken(T : String; Out AHint : TPasMemberHint) : boolean;
     Function IsProcModifier(S : String; Out PM : TProcedureModifier) : Boolean;
     Function IsCallingConvention(S : String; out CC : TCallingConvention) : Boolean;
    @@ -497,7 +498,8 @@
     
     function ParseSource(AEngine: TPasTreeContainer;
       const FPCCommandLine, OSTarget, CPUTarget: String;
    -  UseStreams  : Boolean = False): TPasModule;
    +  UseStreams  : Boolean = False;
    +  CreateDefaultDefs  : Boolean = true): TPasModule;
     var
       FileResolver: TFileResolver;
       Parser: TPasParser;
    @@ -557,48 +559,51 @@
         FileResolver := TFileResolver.Create;
         FileResolver.UseStreams:=UseStreams;
         Scanner := TPascalScanner.Create(FileResolver);
    -    Scanner.AddDefine('FPK');
    -    Scanner.AddDefine('FPC');
         SCanner.LogEvents:=AEngine.ScannerLogEvents;
         SCanner.OnLog:=AEngine.Onlog;
     
    -    // TargetOS
    -    s := UpperCase(OSTarget);
    -    Scanner.AddDefine(s);
    -    if s = 'LINUX' then
    -      Scanner.AddDefine('UNIX')
    -    else if s = 'FREEBSD' then
    +    if CreateDefaultDefs then
         begin
    -      Scanner.AddDefine('BSD');
    -      Scanner.AddDefine('UNIX');
    -    end else if s = 'NETBSD' then
    -    begin
    -      Scanner.AddDefine('BSD');
    -      Scanner.AddDefine('UNIX');
    -    end else if s = 'SUNOS' then
    -    begin
    -      Scanner.AddDefine('SOLARIS');
    -      Scanner.AddDefine('UNIX');
    -    end else if s = 'GO32V2' then
    -      Scanner.AddDefine('DPMI')
    -    else if s = 'BEOS' then
    -      Scanner.AddDefine('UNIX')
    -    else if s = 'QNX' then
    -      Scanner.AddDefine('UNIX')
    -    else if s = 'AROS' then
    -      Scanner.AddDefine('HASAMIGA')
    -    else if s = 'MORPHOS' then
    -      Scanner.AddDefine('HASAMIGA')
    -    else if s = 'AMIGA' then
    -      Scanner.AddDefine('HASAMIGA');
    +      Scanner.AddDefine('FPK');
    +      Scanner.AddDefine('FPC');
    +      // TargetOS
    +      s := UpperCase(OSTarget);
    +      Scanner.AddDefine(s);
    +      if s = 'LINUX' then
    +        Scanner.AddDefine('UNIX')
    +      else if s = 'FREEBSD' then
    +      begin
    +        Scanner.AddDefine('BSD');
    +        Scanner.AddDefine('UNIX');
    +      end else if s = 'NETBSD' then
    +      begin
    +        Scanner.AddDefine('BSD');
    +        Scanner.AddDefine('UNIX');
    +      end else if s = 'SUNOS' then
    +      begin
    +        Scanner.AddDefine('SOLARIS');
    +        Scanner.AddDefine('UNIX');
    +      end else if s = 'GO32V2' then
    +        Scanner.AddDefine('DPMI')
    +      else if s = 'BEOS' then
    +        Scanner.AddDefine('UNIX')
    +      else if s = 'QNX' then
    +        Scanner.AddDefine('UNIX')
    +      else if s = 'AROS' then
    +        Scanner.AddDefine('HASAMIGA')
    +      else if s = 'MORPHOS' then
    +        Scanner.AddDefine('HASAMIGA')
    +      else if s = 'AMIGA' then
    +        Scanner.AddDefine('HASAMIGA');
     
    -    // TargetCPU
    -    s := UpperCase(CPUTarget);
    -    Scanner.AddDefine('CPU'+s);
    -    if (s='X86_64') then
    -      Scanner.AddDefine('CPU64')
    -    else
    -      Scanner.AddDefine('CPU32');
    +      // TargetCPU
    +      s := UpperCase(CPUTarget);
    +      Scanner.AddDefine('CPU'+s);
    +      if (s='X86_64') then
    +        Scanner.AddDefine('CPU64')
    +      else
    +        Scanner.AddDefine('CPU32');
    +    end;
     
         Parser := TPasParser.Create(Scanner, FileResolver, AEngine);
         Filename := '';
    

Activities

Andrey Zubarev

2017-04-21 21:30

reporter  

pparser_ParseSource_CreateDefaultDefs.pp.patch (3,802 bytes)
Index: packages/fcl-passrc/src/pparser.pp
===================================================================
--- packages/fcl-passrc/src/pparser.pp	(revision 35878)
+++ packages/fcl-passrc/src/pparser.pp	(working copy)
@@ -402,7 +402,8 @@
 
 function ParseSource(AEngine: TPasTreeContainer;
                      const FPCCommandLine, OSTarget, CPUTarget: String;
-                     UseStreams  : Boolean = False): TPasModule;
+                     UseStreams  : Boolean = False;
+                     CreateDefaultDefs  : Boolean = true): TPasModule;
 Function IsHintToken(T : String; Out AHint : TPasMemberHint) : boolean;
 Function IsProcModifier(S : String; Out PM : TProcedureModifier) : Boolean;
 Function IsCallingConvention(S : String; out CC : TCallingConvention) : Boolean;
@@ -497,7 +498,8 @@
 
 function ParseSource(AEngine: TPasTreeContainer;
   const FPCCommandLine, OSTarget, CPUTarget: String;
-  UseStreams  : Boolean = False): TPasModule;
+  UseStreams  : Boolean = False;
+  CreateDefaultDefs  : Boolean = true): TPasModule;
 var
   FileResolver: TFileResolver;
   Parser: TPasParser;
@@ -557,48 +559,51 @@
     FileResolver := TFileResolver.Create;
     FileResolver.UseStreams:=UseStreams;
     Scanner := TPascalScanner.Create(FileResolver);
-    Scanner.AddDefine('FPK');
-    Scanner.AddDefine('FPC');
     SCanner.LogEvents:=AEngine.ScannerLogEvents;
     SCanner.OnLog:=AEngine.Onlog;
 
-    // TargetOS
-    s := UpperCase(OSTarget);
-    Scanner.AddDefine(s);
-    if s = 'LINUX' then
-      Scanner.AddDefine('UNIX')
-    else if s = 'FREEBSD' then
+    if CreateDefaultDefs then
     begin
-      Scanner.AddDefine('BSD');
-      Scanner.AddDefine('UNIX');
-    end else if s = 'NETBSD' then
-    begin
-      Scanner.AddDefine('BSD');
-      Scanner.AddDefine('UNIX');
-    end else if s = 'SUNOS' then
-    begin
-      Scanner.AddDefine('SOLARIS');
-      Scanner.AddDefine('UNIX');
-    end else if s = 'GO32V2' then
-      Scanner.AddDefine('DPMI')
-    else if s = 'BEOS' then
-      Scanner.AddDefine('UNIX')
-    else if s = 'QNX' then
-      Scanner.AddDefine('UNIX')
-    else if s = 'AROS' then
-      Scanner.AddDefine('HASAMIGA')
-    else if s = 'MORPHOS' then
-      Scanner.AddDefine('HASAMIGA')
-    else if s = 'AMIGA' then
-      Scanner.AddDefine('HASAMIGA');
+      Scanner.AddDefine('FPK');
+      Scanner.AddDefine('FPC');
+      // TargetOS
+      s := UpperCase(OSTarget);
+      Scanner.AddDefine(s);
+      if s = 'LINUX' then
+        Scanner.AddDefine('UNIX')
+      else if s = 'FREEBSD' then
+      begin
+        Scanner.AddDefine('BSD');
+        Scanner.AddDefine('UNIX');
+      end else if s = 'NETBSD' then
+      begin
+        Scanner.AddDefine('BSD');
+        Scanner.AddDefine('UNIX');
+      end else if s = 'SUNOS' then
+      begin
+        Scanner.AddDefine('SOLARIS');
+        Scanner.AddDefine('UNIX');
+      end else if s = 'GO32V2' then
+        Scanner.AddDefine('DPMI')
+      else if s = 'BEOS' then
+        Scanner.AddDefine('UNIX')
+      else if s = 'QNX' then
+        Scanner.AddDefine('UNIX')
+      else if s = 'AROS' then
+        Scanner.AddDefine('HASAMIGA')
+      else if s = 'MORPHOS' then
+        Scanner.AddDefine('HASAMIGA')
+      else if s = 'AMIGA' then
+        Scanner.AddDefine('HASAMIGA');
 
-    // TargetCPU
-    s := UpperCase(CPUTarget);
-    Scanner.AddDefine('CPU'+s);
-    if (s='X86_64') then
-      Scanner.AddDefine('CPU64')
-    else
-      Scanner.AddDefine('CPU32');
+      // TargetCPU
+      s := UpperCase(CPUTarget);
+      Scanner.AddDefine('CPU'+s);
+      if (s='X86_64') then
+        Scanner.AddDefine('CPU64')
+      else
+        Scanner.AddDefine('CPU32');
+    end;
 
     Parser := TPasParser.Create(Scanner, FileResolver, AEngine);
     Filename := '';

Michael Van Canneyt

2017-04-22 11:26

administrator   ~0099758

Fixed this somewhat different, I introduced TParseSourceOPtions.

Andrey Zubarev

2017-04-22 11:57

reporter   ~0099760

Ok. Thanks!

Issue History

Date Modified Username Field Change
2017-04-21 21:30 Andrey Zubarev New Issue
2017-04-21 21:30 Andrey Zubarev File Added: pparser_ParseSource_CreateDefaultDefs.pp.patch
2017-04-21 22:58 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-04-21 22:58 Michael Van Canneyt Status new => assigned
2017-04-22 11:26 Michael Van Canneyt Fixed in Revision => 35889
2017-04-22 11:26 Michael Van Canneyt Note Added: 0099758
2017-04-22 11:26 Michael Van Canneyt Status assigned => resolved
2017-04-22 11:26 Michael Van Canneyt Fixed in Version => 3.1.1
2017-04-22 11:26 Michael Van Canneyt Resolution open => fixed
2017-04-22 11:26 Michael Van Canneyt Target Version => 3.2.0
2017-04-22 11:57 Andrey Zubarev Note Added: 0099760
2017-04-22 11:57 Andrey Zubarev Status resolved => closed