Skip to content

Commit

Permalink
Match the pragma behavior of optimize_code and additional_branch_opti…
Browse files Browse the repository at this point in the history
…mization to CLI behavior (#459)

Previously, using #pragma compile_with optimize_code didn't actually enable extra_syntax_checks,
like the CLI version did. Even worse happened with additional_branch_optimization,
which disabled extra_syntax_checks if additional_branch_optimization was disabled.

Fix this so that the behavior is exactly the same as when compiling via CLI
  • Loading branch information
mkruselj authored Aug 12, 2024
1 parent aec5c01 commit bfd0d9f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compiler/ksp_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2301,9 +2301,14 @@ def compile(self, callback = None):
if option == 'extra_syntax_checks':
self.extra_syntax_checks = value
if option == 'optimize_code':
if self.extra_syntax_checks == False and value:
self.extra_syntax_checks = value

self.optimize = value
if option == 'extra_branch_optimization':
self.extra_syntax_checks = value
if self.extra_syntax_checks == False and value:
self.extra_syntax_checks = value

self.additional_branch_optimization = value
if option == 'add_compile_date':
self.add_compiled_date_comment = value
Expand Down Expand Up @@ -2478,7 +2483,7 @@ def __repr__(self):
basepath = os.path.dirname(args.source_file.name)

# make sure that extra syntax checks are enabled if --optimize or --extra_branch_optimization arguments are used
if (args.optimize == True or args.additional_branch_optimization) and args.extra_syntax_checks == False:
if (args.optimize or args.additional_branch_optimization) and args.extra_syntax_checks == False:
args.extra_syntax_checks = True

# read the source and compile it
Expand Down

0 comments on commit bfd0d9f

Please sign in to comment.