]> git.ipfire.org Git - thirdparty/gcc.git/commit
libcpp: Fix ICE on #include after a line marker directive [PR61474]
authorLewis Hyatt <lhyatt@gmail.com>
Fri, 15 Sep 2023 17:31:51 +0000 (13:31 -0400)
committerLewis Hyatt <lhyatt@gmail.com>
Wed, 20 Sep 2023 20:44:24 +0000 (16:44 -0400)
commit601dbf2a799f691688dfe78250b5bea2717b5b5e
treeb5309aa08914667b85299fe105b7c5881910a495
parentb512d705797a65dbfe3a9ad100218192c7528b02
libcpp: Fix ICE on #include after a line marker directive [PR61474]

As noted in the PR, GCC will segfault if a file name is first seen in a
linemarker directive, and then later seen in a normal #include.  This is
because the fake include process adds the file to the cache with a null PATH
member. The normal #include finds this file in the cache and then attempts
to use the null PATH.  Resolve by adding the file to the cache with a unique
starting directory, so that the fake entry will only be found by a
subsequent fake include, not by a real one.

libcpp/ChangeLog:

PR preprocessor/61474
* files.cc (_cpp_find_file): Set DONT_READ to TRUE for fake
include files.
(_cpp_fake_include): Pass a unique cpp_dir* address so
the fake file will not be found when looked up for real.

gcc/testsuite/ChangeLog:

PR preprocessor/61474
* c-c++-common/cpp/pr61474-2.h: New test.
* c-c++-common/cpp/pr61474.c: New test.
* c-c++-common/cpp/pr61474.h: New test.
gcc/testsuite/c-c++-common/cpp/pr61474-2.h [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/pr61474.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/pr61474.h [new file with mode: 0644]
libcpp/files.cc