__has_include with angle-bracketed argument breaks preprocessing
Preprocessing (in C++17 mode) of code like this:
#if __has_include(<any>)
#endif
results in an error:
/tmp/fail.cpp:1: syntax error: failed to evaluate #if condition
This happens regardless of whether the mentioned header file exists or not.
Debugging shows that <any> is split in 3 tokens: <, any, >, but the code for handling __has_include expects one token as argument: https://github.com/danmar/simplecpp/blob/ab680f96ea9aa0fc7ed241f6dc51954d7a8d6735/simplecpp.cpp
As a result the check to matching closing parenthesis fails (as any is not )) and a fatal syntax error is reported: https://github.com/danmar/simplecpp/blob/ab680f96ea9aa0fc7ed241f6dc51954d7a8d6735/simplecpp.cpp
This also affects Cppcheck - it reports preprocessorErrorDirective on that line and stops.
ouch I thought this __has_include was fixed by now. Thanks for reporting!
have we been able to fix this? or should someone submit a pull request?
Follow up: are we actually finding the correct file? in that code is it actually searching for < when we are searching the file? does it actually try to open any ?
I didn't have time to look at this yet. A PR would be appreciated.
Follow up:
not sure I'd have to look in the code and/or debug..