summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2025-11-18 13:19:53 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2025-11-18 17:18:10 +0000
commitbad5acbfa77cfd9e46a3f14e3fd79f0fbd8d4bb6 (patch)
tree26ad56826e5680205e8a5fb268046d2fd105e3ff
parent24f252c917089486e1f0d6c0b98962091b6b21d2 (diff)
c++: Handle absolute path for CMI output directory [PR122677]
When trying to create each directory component of an absolute path, the first call to mkdir uses a path of "" which gives an ENOENT error. This causes the create_dirs function to return without creating anything. This commit skips past the leading slashes of an absolute path, so that the first call to mkdir is for an actual directory name, not an empty string. gcc/cp/ChangeLog: PR c++/122677 * module.cc (create_dirs): Skip past any leading slashes. (cherry picked from commit c1cf465bdbe587b1ccd8feb05b9b3878163708fe)
-rw-r--r--gcc/cp/module.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index b7e137124b2..8490b64e233 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -4884,8 +4884,13 @@ maybe_add_cmi_prefix (const char *to, size_t *len_p = NULL)
static void
create_dirs (char *path)
{
+ char *base = path;
+ /* Skip past initial slashes of absolute path. */
+ while (IS_DIR_SEPARATOR (*base))
+ base++;
+
/* Try and create the missing directories. */
- for (char *base = path; *base; base++)
+ for (; *base; base++)
if (IS_DIR_SEPARATOR (*base))
{
char sep = *base;