Bladeren bron

* delay effect of {$calling x} until switches are flushed (mantis #12985)

git-svn-id: trunk@12932 -
Jonas Maebe 16 jaren geleden
bovenliggende
commit
bf7c9361f6
5 gewijzigde bestanden met toevoegingen van 36 en 8 verwijderingen
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/globals.pas
  3. 4 7
      compiler/scandir.pas
  4. 12 0
      compiler/switches.pas
  5. 17 0
      tests/webtbs/tw12985.pp

+ 1 - 0
.gitattributes

@@ -8784,6 +8784,7 @@ tests/webtbs/tw1284.pp svneol=native#text/plain
 tests/webtbs/tw1286.pp svneol=native#text/plain
 tests/webtbs/tw12942.pp svneol=native#text/plain
 tests/webtbs/tw1295.pp svneol=native#text/plain
+tests/webtbs/tw12985.pp svneol=native#text/plain
 tests/webtbs/tw1299.pp svneol=native#text/plain
 tests/webtbs/tw12993.pp svneol=native#text/plain
 tests/webtbs/tw13015.pp svneol=native#text/plain

+ 2 - 1
compiler/globals.pas

@@ -171,9 +171,10 @@ interface
       end;
 
       tpendingstate = record
-        nextverbositystr : string;
+        nextverbositystr : shortstring;
         nextlocalswitches : tlocalswitches;
         nextverbosityfullswitch: longint;
+        nextcallingstr : shortstring;
         verbosityfullswitched,
         localswitcheschanged : boolean;
       end;

+ 4 - 7
compiler/scandir.pas

@@ -271,13 +271,10 @@ implementation
       begin
         current_scanner.skipspace;
         hs:=current_scanner.readid;
-        if not SetAktProcCall(hs,current_settings.defproccall) then
-          begin
-            if (hs <> '') then
-              Message1(parser_w_unknown_proc_directive_ignored,hs)
-            else
-              Message(parser_e_proc_directive_expected);
-          end;
+        if (hs='') then
+          Message(parser_e_proc_directive_expected)
+        else
+          recordpendingcallingswitch(hs);
       end;
 
 

+ 12 - 0
compiler/switches.pas

@@ -35,6 +35,7 @@ procedure recordpendingverbosityswitch(sw: char; state: char);
 procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
 procedure recordpendinglocalfullswitch(const switches: tlocalswitches);
 procedure recordpendingverbosityfullswitch(verbosity: longint);
+procedure recordpendingcallingswitch(const str: shortstring);
 procedure flushpendingswitchesstate;
 
 implementation
@@ -296,6 +297,11 @@ procedure recordpendingverbosityfullswitch(verbosity: longint);
     pendingstate.verbosityfullswitched:=true;
   end;
 
+procedure recordpendingcallingswitch(const str: shortstring);
+  begin
+    pendingstate.nextcallingstr:=str;
+  end;
+
 
 procedure flushpendingswitchesstate;
   begin
@@ -314,6 +320,12 @@ procedure flushpendingswitchesstate;
         setverbosity(pendingstate.nextverbositystr);
         pendingstate.nextverbositystr:='';
       end;
+    if pendingstate.nextcallingstr<>'' then
+      begin
+        if not SetAktProcCall(pendingstate.nextcallingstr,current_settings.defproccall) then
+          Message1(parser_w_unknown_proc_directive_ignored,pendingstate.nextcallingstr);
+        pendingstate.nextcallingstr:='';
+      end;
   end;
 
 

+ 17 - 0
tests/webtbs/tw12985.pp

@@ -0,0 +1,17 @@
+{ %norun }
+
+{ if the compiler is still buggy and consumed the "calling stdcall" while
+  parsing the forward definition of test, it will complain about a calling
+  convention mismatch when parsing the actual definition
+}
+
+{$calling register}
+function test(l1,l2: longint): longint; forward;
+{$calling stdcall}
+
+function test(l1,l2: longint): longint; register;
+begin
+end;
+
+begin
+end.