Browse Source

+ support for Delphi's {$w-/+} switch (force stackframe generation for
assembler routines or not) (mantis #6687)

git-svn-id: trunk@6151 -

Jonas Maebe 18 years ago
parent
commit
ddd071b2e4
3 changed files with 44 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 2 0
      compiler/psub.pas
  3. 41 0
      tests/webtbs/tw6687.pp

+ 1 - 0
.gitattributes

@@ -7921,6 +7921,7 @@ tests/webtbs/tw6624.pp svneol=native#text/plain
 tests/webtbs/tw6641.pp svneol=native#text/plain
 tests/webtbs/tw6641.pp svneol=native#text/plain
 tests/webtbs/tw6684.pp svneol=native#text/plain
 tests/webtbs/tw6684.pp svneol=native#text/plain
 tests/webtbs/tw6686.pp svneol=native#text/plain
 tests/webtbs/tw6686.pp svneol=native#text/plain
+tests/webtbs/tw6687.pp svneol=native#text/plain
 tests/webtbs/tw6700.pp svneol=native#text/plain
 tests/webtbs/tw6700.pp svneol=native#text/plain
 tests/webtbs/tw6735.pp svneol=native#text/plain
 tests/webtbs/tw6735.pp svneol=native#text/plain
 tests/webtbs/tw6742.pp svneol=native#text/plain
 tests/webtbs/tw6742.pp svneol=native#text/plain

+ 2 - 0
compiler/psub.pas

@@ -776,6 +776,7 @@ implementation
              or
              or
               - Delphi mode
               - Delphi mode
               - assembler directive
               - assembler directive
+              - no cs_generate_stackframes in localswitches
               - no pushes are used/esp modifications, could be:
               - no pushes are used/esp modifications, could be:
                 * outgoing parameters on the stack
                 * outgoing parameters on the stack
                 * incoming parameters on the stack
                 * incoming parameters on the stack
@@ -783,6 +784,7 @@ implementation
               - no local variables
               - no local variables
             }
             }
             if ((po_assembler in procdef.procoptions) and
             if ((po_assembler in procdef.procoptions) and
+                not(cs_generate_stackframes in current_settings.localswitches) and
                 (m_delphi in current_settings.modeswitches) and
                 (m_delphi in current_settings.modeswitches) and
                 (tabstractlocalsymtable(procdef.localst).count_locals = 0)) or
                 (tabstractlocalsymtable(procdef.localst).count_locals = 0)) or
                ((cs_opt_stackframe in current_settings.optimizerswitches) and
                ((cs_opt_stackframe in current_settings.optimizerswitches) and

+ 41 - 0
tests/webtbs/tw6687.pp

@@ -0,0 +1,41 @@
+{ %cpu=i386 }
+{ %target=win32,linux,freebsd }
+
+{$w+}
+
+{$ifdef fpc}
+{$mode delphi}
+{$endif}
+
+{ should generate a stack frame because of w+ above }
+function testje(l1,l2,l3: longint): longint;
+asm
+  mov eax, 30000
+  leave
+  ret
+end;
+
+function test: longint;
+var
+  l1,l2,l3,l4,l5: cardinal;
+begin
+  test := 12345;
+  l1 := $f00beef;
+  l2 := $cafebabe;
+  l3 := $c001d00d;
+  l4 := $12345678;
+  l5 := $90abcdef;
+  if testje(1,2,3) <> 30000 then
+    halt(1);
+  if (l1 <> $f00beef) or
+     (l2 <> $cafebabe) or
+     (l3 <> $c001d00d) or
+     (l4 <> $12345678) or
+     (l5 <> $90abcdef) then
+    halt(2);
+end;
+
+begin
+  if test <> 12345 then
+    halt(3);
+end.