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.
This commit is contained in:
Stephen Heumann 2017-07-12 00:28:11 -05:00
parent 1502e48188
commit 5969d80e57

View File

@ -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}