Skip to content

fix preprocessor: nested #ifdef ... #else#2373

Merged
guwirth merged 1 commit intoSonarOpenCommunity:masterfrom
guwirth:fix-ifdef
May 12, 2022
Merged

fix preprocessor: nested #ifdef ... #else#2373
guwirth merged 1 commit intoSonarOpenCommunity:masterfrom
guwirth:fix-ifdef

Conversation

@guwirth
Copy link
Copy Markdown
Collaborator

@guwirth guwirth commented May 12, 2022

In case of nested #ifdef ... #else and false condition, the #else branch was not always parsed by the preprocessor.
This typically leads to syntax errors.

#if !defined A
#define A
#  ifdef B
      // branch a
#  else
      // branch b <== sometimes not parsed
#  endif
#endif

This change is Reviewable

In case of nested #ifdef ... #else and false condition, the #else branch was not always parsed by the preprocessor.
This typically leads to syntax errors (close SonarOpenCommunity#2336).

```C++
#if !defined A
#define A
#  ifdef B
      // branch a
#  else
      // branch b
#  endif
#endif
```
@guwirth guwirth added the bug label May 12, 2022
@guwirth guwirth added this to the 2.1.0 milestone May 12, 2022
@guwirth guwirth self-assigned this May 12, 2022
@guwirth guwirth merged commit fb659fd into SonarOpenCommunity:master May 12, 2022
@guwirth guwirth deleted the fix-ifdef branch July 26, 2022 09:10
@guwirth guwirth restored the fix-ifdef branch July 26, 2022 09:14
@guwirth guwirth deleted the fix-ifdef branch February 8, 2023 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Parse error - different base classes

1 participant