https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110558
Lewis Hyatt <lhyatt at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2023-12-11 CC| |lhyatt at gcc dot gnu.org --- Comment #4 from Lewis Hyatt <lhyatt at gcc dot gnu.org> --- __has_include was added I think in GCC 5, and re-implemented in GCC 10, but this issue with padding in the macro expansion was never handled correctly it seems. I am testing the below which will fix it, will submit it soon with a testcase. Not sure if it would be eligible for backport or not, but it would apply cleanly to all active branches also. diff --git a/libcpp/macro.cc b/libcpp/macro.cc index 6f24a9d6f3a..15140c60023 100644 --- a/libcpp/macro.cc +++ b/libcpp/macro.cc @@ -398,6 +398,8 @@ builtin_has_include (cpp_reader *pfile, cpp_hashnode *op, bool has_next) NODE_NAME (op)); pfile->state.angled_headers = true; + const auto sav_padding = pfile->state.directive_wants_padding; + pfile->state.directive_wants_padding = true; const cpp_token *token = cpp_get_token_no_padding (pfile); bool paren = token->type == CPP_OPEN_PAREN; if (paren) @@ -406,6 +408,7 @@ builtin_has_include (cpp_reader *pfile, cpp_hashnode *op, bool has_next) cpp_error (pfile, CPP_DL_ERROR, "missing '(' before \"%s\" operand", NODE_NAME (op)); pfile->state.angled_headers = false; + pfile->state.directive_wants_padding = sav_padding; bool bracket = token->type != CPP_STRING; char *fname = NULL;