* [PATCH] gcc: Make strchr return value pointers const
@ 2020-09-01 13:01 Martin Storsjö
2020-09-04 9:21 ` JonY
2020-09-04 9:32 ` Jakub Jelinek
0 siblings, 2 replies; 10+ messages in thread
From: Martin Storsjö @ 2020-09-01 13:01 UTC (permalink / raw)
To: gcc-patches
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-01 Martin Storsjö <martin@martin.st>
gcc/Changelog:
* dwarf2out.c (file_name_acquire): Make a strchr return value
pointer to const.
libcpp/Changelog:
* files.c (remap_filename): Make a strchr return value pointer
to const.
---
gcc/dwarf2out.c | 2 +-
libcpp/files.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index b6ab49bb548..4096c0c0d69 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -12118,7 +12118,7 @@ file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad)
f = strrchr (f, DIR_SEPARATOR);
#if defined (DIR_SEPARATOR_2)
{
- char *g = strrchr (fi->path, DIR_SEPARATOR_2);
+ const char *g = strrchr (fi->path, DIR_SEPARATOR_2);
if (g != NULL)
{
diff --git a/libcpp/files.c b/libcpp/files.c
index 3d48c38fc0a..b890b8ebf1e 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -1693,7 +1693,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
p = strchr (fname, '/');
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
{
- char *p2 = strchr (fname, '\\');
+ const char *p2 = strchr (fname, '\\');
if (!p || (p > p2))
p = p2;
}
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gcc: Make strchr return value pointers const
2020-09-01 13:01 [PATCH] gcc: Make strchr return value pointers const Martin Storsjö
@ 2020-09-04 9:21 ` JonY
2020-09-04 9:32 ` Jakub Jelinek
1 sibling, 0 replies; 10+ messages in thread
From: JonY @ 2020-09-04 9:21 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1.1: Type: text/plain, Size: 385 bytes --]
On 9/1/20 1:01 PM, Martin Storsjö wrote:
> 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.
>
Ping any reviewers?
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gcc: Make strchr return value pointers const
2020-09-01 13:01 [PATCH] gcc: Make strchr return value pointers const Martin Storsjö
2020-09-04 9:21 ` JonY
@ 2020-09-04 9:32 ` Jakub Jelinek
2020-09-04 12:47 ` Martin Storsjö
1 sibling, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2020-09-04 9:32 UTC (permalink / raw)
To: Martin Storsjö, JonY; +Cc: gcc-patches
On Tue, Sep 01, 2020 at 04:01:42PM +0300, Martin Storsjö wrote:
> 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.
Not really specific to clang, e.g. glibc does that in its headers too
as the C++ standard mandates that (and I guess mingw should do that too).
> This matches similar variables outside of the ifdefs for dos-like
> path handling.
>
> 2020-09-01 Martin Storsjö <martin@martin.st>
>
> gcc/Changelog:
> * dwarf2out.c (file_name_acquire): Make a strchr return value
> pointer to const.
>
> libcpp/Changelog:
> * files.c (remap_filename): Make a strchr return value pointer
> to const.
LGTM. And it is short enough not to need copyright assignment, so ok for
trunk.
> ---
> gcc/dwarf2out.c | 2 +-
> libcpp/files.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index b6ab49bb548..4096c0c0d69 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -12118,7 +12118,7 @@ file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad)
> f = strrchr (f, DIR_SEPARATOR);
> #if defined (DIR_SEPARATOR_2)
> {
> - char *g = strrchr (fi->path, DIR_SEPARATOR_2);
> + const char *g = strrchr (fi->path, DIR_SEPARATOR_2);
>
> if (g != NULL)
> {
> diff --git a/libcpp/files.c b/libcpp/files.c
> index 3d48c38fc0a..b890b8ebf1e 100644
> --- a/libcpp/files.c
> +++ b/libcpp/files.c
> @@ -1693,7 +1693,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
> p = strchr (fname, '/');
> #ifdef HAVE_DOS_BASED_FILE_SYSTEM
> {
> - char *p2 = strchr (fname, '\\');
> + const char *p2 = strchr (fname, '\\');
> if (!p || (p > p2))
> p = p2;
> }
> --
> 2.17.1
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gcc: Make strchr return value pointers const
2020-09-04 9:32 ` Jakub Jelinek
@ 2020-09-04 12:47 ` Martin Storsjö
2020-09-08 0:13 ` JonY
0 siblings, 1 reply; 10+ messages in thread
From: Martin Storsjö @ 2020-09-04 12:47 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: JonY, gcc-patches
Hi,
On Fri, 4 Sep 2020, Jakub Jelinek wrote:
> On Tue, Sep 01, 2020 at 04:01:42PM +0300, Martin Storsjö wrote:
>> 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.
>
> Not really specific to clang, e.g. glibc does that in its headers too
> as the C++ standard mandates that (and I guess mingw should do that too).
>
>> This matches similar variables outside of the ifdefs for dos-like
>> path handling.
>>
>> 2020-09-01 Martin Storsjö <martin@martin.st>
>>
>> gcc/Changelog:
>> * dwarf2out.c (file_name_acquire): Make a strchr return value
>> pointer to const.
>>
>> libcpp/Changelog:
>> * files.c (remap_filename): Make a strchr return value pointer
>> to const.
>
> LGTM. And it is short enough not to need copyright assignment, so ok for
> trunk.
Thanks! Can someone commit this for me?
// Martin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gcc: Make strchr return value pointers const
2020-09-04 12:47 ` Martin Storsjö
@ 2020-09-08 0:13 ` JonY
2020-09-08 11:16 ` Richard Sandiford
2020-09-17 3:56 ` Jeff Law
0 siblings, 2 replies; 10+ messages in thread
From: JonY @ 2020-09-08 0:13 UTC (permalink / raw)
To: Martin Storsjö, Jakub Jelinek; +Cc: gcc-patches
[-- Attachment #1.1: Type: text/plain, Size: 1348 bytes --]
On 9/4/20 12:47 PM, Martin Storsjö wrote:
> Hi,
>
> On Fri, 4 Sep 2020, Jakub Jelinek wrote:
>
>> On Tue, Sep 01, 2020 at 04:01:42PM +0300, Martin Storsjö wrote:
>>> 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.
>>
>> Not really specific to clang, e.g. glibc does that in its headers too
>> as the C++ standard mandates that (and I guess mingw should do that too).
>>
>>> This matches similar variables outside of the ifdefs for dos-like
>>> path handling.
>>>
>>> 2020-09-01 Martin Storsjö <martin@martin.st>
>>>
>>> gcc/Changelog:
>>> * dwarf2out.c (file_name_acquire): Make a strchr return value
>>> pointer to const.
>>>
>>> libcpp/Changelog:
>>> * files.c (remap_filename): Make a strchr return value pointer
>>> to const.
>>
>> LGTM. And it is short enough not to need copyright assignment, so ok for
>> trunk.
>
> Thanks! Can someone commit this for me?
>
> // Martin
Ping can anyone commit this?
Are platform maintainers allowed to push general changes like these? If
so I can push soon.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gcc: Make strchr return value pointers const
2020-09-08 0:13 ` JonY
@ 2020-09-08 11:16 ` Richard Sandiford
2020-09-08 11:50 ` Jakub Jelinek
2020-09-17 3:56 ` Jeff Law
1 sibling, 1 reply; 10+ messages in thread
From: Richard Sandiford @ 2020-09-08 11:16 UTC (permalink / raw)
To: JonY via Gcc-patches; +Cc: Martin Storsjö, Jakub Jelinek, JonY
JonY via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> On 9/4/20 12:47 PM, Martin Storsjö wrote:
>> Hi,
>>
>> On Fri, 4 Sep 2020, Jakub Jelinek wrote:
>>
>>> On Tue, Sep 01, 2020 at 04:01:42PM +0300, Martin Storsjö wrote:
>>>> 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.
>>>
>>> Not really specific to clang, e.g. glibc does that in its headers too
>>> as the C++ standard mandates that (and I guess mingw should do that too).
>>>
>>>> This matches similar variables outside of the ifdefs for dos-like
>>>> path handling.
>>>>
>>>> 2020-09-01 Martin Storsjö <martin@martin.st>
>>>>
>>>> gcc/Changelog:
>>>> * dwarf2out.c (file_name_acquire): Make a strchr return value
>>>> pointer to const.
>>>>
>>>> libcpp/Changelog:
>>>> * files.c (remap_filename): Make a strchr return value pointer
>>>> to const.
>>>
>>> LGTM. And it is short enough not to need copyright assignment, so ok for
>>> trunk.
>>
>> Thanks! Can someone commit this for me?
>>
>> // Martin
>
> Ping can anyone commit this?
>
> Are platform maintainers allowed to push general changes like these? If
> so I can push soon.
Yeah, anyone with commit access can push an approved patch.
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gcc: Make strchr return value pointers const
2020-09-08 0:13 ` JonY
2020-09-08 11:16 ` Richard Sandiford
@ 2020-09-17 3:56 ` Jeff Law
2020-09-17 6:19 ` JonY
1 sibling, 1 reply; 10+ messages in thread
From: Jeff Law @ 2020-09-17 3:56 UTC (permalink / raw)
To: JonY, Martin Storsjö, Jakub Jelinek; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1567 bytes --]
On 9/7/20 6:13 PM, JonY via Gcc-patches wrote:
> On 9/4/20 12:47 PM, Martin Storsjö wrote:
>> Hi,
>>
>> On Fri, 4 Sep 2020, Jakub Jelinek wrote:
>>
>>> On Tue, Sep 01, 2020 at 04:01:42PM +0300, Martin Storsjö wrote:
>>>> 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.
>>> Not really specific to clang, e.g. glibc does that in its headers too
>>> as the C++ standard mandates that (and I guess mingw should do that too).
>>>
>>>> This matches similar variables outside of the ifdefs for dos-like
>>>> path handling.
>>>>
>>>> 2020-09-01 Martin Storsjö <martin@martin.st>
>>>>
>>>> gcc/Changelog:
>>>> * dwarf2out.c (file_name_acquire): Make a strchr return value
>>>> pointer to const.
>>>>
>>>> libcpp/Changelog:
>>>> * files.c (remap_filename): Make a strchr return value pointer
>>>> to const.
>>> LGTM. And it is short enough not to need copyright assignment, so ok for
>>> trunk.
>> Thanks! Can someone commit this for me?
>>
>> // Martin
> Ping can anyone commit this?
>
> Are platform maintainers allowed to push general changes like these? If
> so I can push soon.
If it's been ack'd by a maintainer, yes. Jakub definitely qualifies as
a maintainer, so feel free to push it on Martin's behalf.
jeff
>
[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1763 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gcc: Make strchr return value pointers const
2020-09-17 3:56 ` Jeff Law
@ 2020-09-17 6:19 ` JonY
0 siblings, 0 replies; 10+ messages in thread
From: JonY @ 2020-09-17 6:19 UTC (permalink / raw)
To: Jeff Law, Martin Storsjö, Jakub Jelinek; +Cc: gcc-patches
[-- Attachment #1.1: Type: text/plain, Size: 238 bytes --]
On 9/17/20 3:56 AM, Jeff Law wrote:
>
> If it's been ack'd by a maintainer, yes. Jakub definitely qualifies as
> a maintainer, so feel free to push it on Martin's behalf.
>
>
> jeff
Sure, it has been pushed, thanks all.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-09-17 6:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 13:01 [PATCH] gcc: Make strchr return value pointers const Martin Storsjö
2020-09-04 9:21 ` JonY
2020-09-04 9:32 ` Jakub Jelinek
2020-09-04 12:47 ` Martin Storsjö
2020-09-08 0:13 ` JonY
2020-09-08 11:16 ` Richard Sandiford
2020-09-08 11:50 ` Jakub Jelinek
2020-09-08 12:03 ` Martin Storsjö
2020-09-17 3:56 ` Jeff Law
2020-09-17 6:19 ` JonY
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).