Skip to content

Commit 3fe3efe

Browse files
mstorsjojakubjelinek
authored andcommitted
gcc: Make strchr return value pointers const
This fixes compilation of codepaths for dos-like filesystems with Clang. When built with clang, it treats C input files as C++ when the compiler driver is invoked in C++ mode, triggering errors when the return value of strchr() on a pointer to const is assigned to a pointer to non-const variable. This matches similar variables outside of the ifdefs for dos-like path handling. 2020-09-07 Martin Storsjö <[email protected]> gcc/ * dwarf2out.c (file_name_acquire): Make a strchr return value pointer to const. libcpp/ * files.c (remap_filename): Make a strchr return value pointer to const.
1 parent 2b0df0a commit 3fe3efe

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

gcc/dwarf2out.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12118,7 +12118,7 @@ file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad)
1211812118
f = strrchr (f, DIR_SEPARATOR);
1211912119
#if defined (DIR_SEPARATOR_2)
1212012120
{
12121-
char *g = strrchr (fi->path, DIR_SEPARATOR_2);
12121+
const char *g = strrchr (fi->path, DIR_SEPARATOR_2);
1212212122

1212312123
if (g != NULL)
1212412124
{

libcpp/files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
16931693
p = strchr (fname, '/');
16941694
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
16951695
{
1696-
char *p2 = strchr (fname, '\\');
1696+
const char *p2 = strchr (fname, '\\');
16971697
if (!p || (p > p2))
16981698
p = p2;
16991699
}

0 commit comments

Comments
 (0)