Skip to content

Add support for {$PUSHOPT}, {$POPOPT} and long {$IFOPT} names - #470

Open
Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:preprocessor-pushopt-popopt-long-ifopt
Open

Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:preprocessor-pushopt-popopt-long-ifopt

Conversation

@Bazooper-blip

Copy link
Copy Markdown
Contributor

This PR adds support for the {$PUSHOPT} and {$POPOPT} directives and for long switch names in {$IFOPT}, both introduced in Delphi 13.

{$PUSHOPT} saves the set of active compiler switches in CompilerSwitchRegistry, and {$POPOPT} restores it: switches that are active at the {$POPOPT} end there, and the saved switches become active again from that point. A {$POPOPT} without a matching {$PUSHOPT} is ignored. As described in #411, PUSHOPT and POPOPT are added to ParameterDirective.ParameterKind.

{$IFOPT} now also accepts long switch names with an ON/OFF value, such as {$IFOPT RANGECHECKS ON}, alongside the existing {$IFOPT R+} form.

{$PUSHOPT} and {$POPOPT} also save and restore warning settings, but the preprocessor doesn't track {$WARN} state, so only compiler switches are covered here.

I noticed #412 is assigned to @jgardn3r, so I'm happy to drop the {$IFOPT} part if it's already in progress.

Fixes #411, fixes #412.

Delphi 13 introduces the `{$PUSHOPT}` and `{$POPOPT}` directives, which
save and restore the current compiler options, and allows long switch
names in `{$IFOPT}` (e.g. `{$IFOPT RANGECHECKS ON}`).

`CompilerSwitchRegistry` now keeps a stack of the active switches. On
`{$POPOPT}`, the currently active switches end at the directive, and
the switches saved by the matching `{$PUSHOPT}` become active again
from that point.

Closes integrated-application-development#411, closes integrated-application-development#412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support long directive names in the {$IFOPT} directive Support {$PUSHOPT} and {$POPOPT} compiler directives

1 participant