clang-format changes semantics of code on '#define keyword(x)' #31086
Labels
bug
Indicates an unexpected problem or unintended behavior
bugzilla
Issues migrated from bugzilla
clang-format
confirmed
Verified by a second party
good first issue
https://github.com/llvm/llvm-project/contribute
invalid-code-generation
Tool (e.g. clang-format) produced invalid code that no longer compiles
Extended Description
For certain keywords, '#define keyword(x)' will erroneously insert an extra space, causing the function-like macro to instead become an object-like macro. This can change the semantics of the compiled code, which should never happen.
The full list of affected C++ keywords seems to be:
and, and_eq, bitor, case, catch, delete, for, if, new, not_eq, or, or_eq, return, switch, try, while, xor, xor_eq. Additionally, the MSVC-specific __except is affected, and __try is not (but I haven't exhaustively tested all of MSVC's keywords.)
Note that this is not the same as the list of keywords which should be followed by a space when used normally according to the current style, or the list of keywords which are recognised by the preprocessor, or the list of keywords which it's grammatically valid for them to be followed by an open-parenthesis. In particular, note that bitor is affected, but bitand is not.
The text was updated successfully, but these errors were encountered: