From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F40D2385E459; Thu, 14 Mar 2024 11:33:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F40D2385E459 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710416033; bh=wryAkM07IgUOK8qtVCgQ2ORVdaPJjnhFowThIheaul8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=u1P76g7wIFargs7RxgiqI5bLAkDQJ6nk3HgGbCaiBQidOcsW6FTqY4ucMrW7BoZCg cypJPNK+IpFHw/dex/KBLerYMkrp2FbwmfHz6JuDmW5cTDw77e6GYLzh7YCmLX+6V4 StrOwJFxWJm1NJAifC+4ePUeY2APdSxJOltVxpy4= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/110558] __has_include argument expansion results in unexpected filename Date: Thu, 14 Mar 2024 11:33:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: unknown X-Bugzilla-Keywords: patch X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110558 --- Comment #6 from GCC Commits --- The master branch has been updated by Lewis Hyatt : https://gcc.gnu.org/g:942497ad74272e0ef16020d628e471c5f21474b0 commit r14-9465-g942497ad74272e0ef16020d628e471c5f21474b0 Author: Lewis Hyatt Date: Tue Dec 12 17:46:36 2023 -0500 libcpp: Fix macro expansion for argument of __has_include [PR110558] When the file name for a #include directive is the result of stringifyi= ng a macro argument, libcpp needs to take some care to get the whitespace correct; in particular stringify_arg() needs to see a CPP_PADDING token between macro tokens so that it can figure out when to output space bet= ween tokens. The CPP_PADDING tokens are not normally generated when handling= a preprocessor directive, but for #include-like directives, libcpp sets t= he state variable pfile->state.directive_wants_padding to TRUE so that the CPP_PADDING tokens will be output, and then everything works fine for computed includes. As the PR points out, things do not work fine for __has_include. Fix th= at by setting the state variable the same as is done for #include. libcpp/ChangeLog: PR preprocessor/110558 * macro.cc (builtin_has_include): Set pfile->state.directive_wants_padding prior to lexing the file name, in case it comes from macro expansion. gcc/testsuite/ChangeLog: PR preprocessor/110558 * c-c++-common/cpp/has-include-2.c: New test. * c-c++-common/cpp/has-include-2.h: New test.=