Browse Source

* check validity of calling conventions specified using {$calling x}
(previously, this was only checked for calling conventions specified
as a procedure directive)

git-svn-id: trunk@12944 -

Jonas Maebe 16 years ago
parent
commit
a7e02c7948
1 changed files with 11 additions and 2 deletions
  1. 11 2
      compiler/switches.pas

+ 11 - 2
compiler/switches.pas

@@ -304,12 +304,16 @@ procedure recordpendingcallingswitch(const str: shortstring);
 
 
 
 
 procedure flushpendingswitchesstate;
 procedure flushpendingswitchesstate;
+  var
+    tmpproccal: tproccalloption;
   begin
   begin
+    { process pending localswitches (range checking, etc) }
     if pendingstate.localswitcheschanged then
     if pendingstate.localswitcheschanged then
       begin
       begin
         current_settings.localswitches:=pendingstate.nextlocalswitches;
         current_settings.localswitches:=pendingstate.nextlocalswitches;
         pendingstate.localswitcheschanged:=false;
         pendingstate.localswitcheschanged:=false;
       end;
       end;
+    { process pending verbosity changes (warnings on, etc) }
     if pendingstate.verbosityfullswitched then
     if pendingstate.verbosityfullswitched then
       begin
       begin
         status.verbosity:=pendingstate.nextverbosityfullswitch;
         status.verbosity:=pendingstate.nextverbosityfullswitch;
@@ -320,10 +324,15 @@ procedure flushpendingswitchesstate;
         setverbosity(pendingstate.nextverbositystr);
         setverbosity(pendingstate.nextverbositystr);
         pendingstate.nextverbositystr:='';
         pendingstate.nextverbositystr:='';
       end;
       end;
+    { process pending calling convention changes (calling x) }
     if pendingstate.nextcallingstr<>'' then
     if pendingstate.nextcallingstr<>'' then
       begin
       begin
-        if not SetAktProcCall(pendingstate.nextcallingstr,current_settings.defproccall) then
-          Message1(parser_w_unknown_proc_directive_ignored,pendingstate.nextcallingstr);
+        if not SetAktProcCall(pendingstate.nextcallingstr,tmpproccal) then
+          Message1(parser_w_unknown_proc_directive_ignored,pendingstate.nextcallingstr)
+        else if not(tmpproccal in supported_calling_conventions) then
+          Message1(parser_e_illegal_calling_convention,pendingstate.nextcallingstr)
+        else
+          current_settings.defproccall:=tmpproccal;
         pendingstate.nextcallingstr:='';
         pendingstate.nextcallingstr:='';
       end;
       end;
   end;
   end;