Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of nested preprocessor if/else blocks #404

Closed
albertziegenhagel opened this issue Jun 3, 2024 · 0 comments · Fixed by #405
Closed

Incorrect handling of nested preprocessor if/else blocks #404

albertziegenhagel opened this issue Jun 3, 2024 · 0 comments · Fixed by #405
Labels
bug Something isn't working

Comments

@albertziegenhagel
Copy link
Contributor

Describe the bug
Given a nested pre-processor block like this:

#if 0
#if 1
#define FOO 1
#endif
#endif

FOO is incorrectly defined to 1. fortls seems to only take the innermost #if into account and ignores that the outer #if statement evaluates to false.

To Reproduce
Given the example above is written to a file pp-nested-if.F90. Executing

python -m fortls --debug_filepath=pp-nested-if.F90 --debug_parser

gives

=== PreProc Pass ===

#if 0 !!! Conditional FALSE(1)
#if 1 !!! Conditional TRUE(2)
#define FOO 1 !!! Define statement(3)
#endif !!! Conditional TRUE/END(4)
#endif !!! Conditional FALSE/END(5)

=== Parsing Pass ===

which shows that the line #define FOO 1 is evaluated.

Expected behavior
FOO should not be defined.

Setup information (please complete the following information):

  • OS: Windows
  • Python Version 3.11
  • fortls Version 3.1.1.dev
@albertziegenhagel albertziegenhagel added the bug Something isn't working label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant