From 5969d80e57fc6aa5fd12919cf5c1ea366100614f Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Wed, 12 Jul 2017 00:28:11 -0500 Subject: [PATCH] If 'volatile' is used within a function, only reduce optimization for that function. Previously, several optimizations would be disabled for the rest of the translation unit whenever the keyword 'volatile' appeared. Now, if 'volatile' is used within a function, it only reduces optimization for that function, since whatever was declared as 'volatile' will be out of scope after the function is over. Uses of 'volatile' outside functions still behave as before. --- Parser.pas | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Parser.pas b/Parser.pas index b84863c..bb85b7d 100644 --- a/Parser.pas +++ b/Parser.pas @@ -154,6 +154,7 @@ var returnLabel: integer; {label for exit point} skipDeclarator: boolean; {for enum,struct,union with no declarator} statementList: statementPtr; {list of open statements} + savedVolatile: boolean; {saved copy of volatile} {parameter processing variables} {------------------------------} @@ -330,6 +331,7 @@ if not doingFunction then begin {if so, finish it off} end; {while} dumpLocal := true; {dump the local pool} nameFound := false; {no pc_nam for the next function (yet)} + volatile := savedVolatile; {local volatile vars are out of scope} end; {if} PopTable; {remove this symbol table} dispose(stPtr); {dump the record} @@ -3529,6 +3531,7 @@ if isFunction then begin GenParameters(nil) else GenParameters(fnType^.parameterList); + savedVolatile := volatile; CompoundStatement(false); {process the statements} end; {else} end; {else}