public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix -Wmissing-attributes warning in libstdc++ (PR libstdc++/89402)
@ 2019-02-20  8:07 Jakub Jelinek
  2019-02-22  1:19 ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2019-02-20  8:07 UTC (permalink / raw)
  To: gcc-patches, libstdc++

Hi!

The following patch fixes a warning when building on targets where long
double switched from being the same as double to something wider,
like e.g. powerpc*-linux, alpha*-linux, s390*-linux etc.

Fixed thusly, bootstrapped/regtested on {x86_64,i686,s390x}-linux and
bootstrapped on powerpc64le-linux, on both s390x and powerpc64le it removed
all
../../../../libstdc++-v3/src/c++98/compatibility-ldbl.cc:77:17: warning: 'void _ZNKSt4hashIeEclEe()' specifies less restrictive attribute than its target 'std::size_t std::tr1::hash<_Tp>::operator()(_Tp) const [with _Tp = long double]': 'pure' [-Wmissing-attributes]
warnings from the build log.  Preapproved by Jonathan in the PR, committed
to trunk.

2019-02-20  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/89402
	* src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Add
	_GLIBCXX_PURE to the alias declaration.

--- libstdc++-v3/src/c++98/compatibility-ldbl.cc.jj	2019-01-01 12:39:41.530606161 +0100
+++ libstdc++-v3/src/c++98/compatibility-ldbl.cc	2019-02-19 16:12:52.402123217 +0100
@@ -75,6 +75,6 @@ namespace std _GLIBCXX_VISIBILITY(defaul
 // and std::hash<long double>::operator()
 // are the same, no need to duplicate them.
 extern "C" void _ZNKSt4hashIeEclEe (void)
-  __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
+  _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
 
 #endif


	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [committed] Fix -Wmissing-attributes warning in libstdc++ (PR libstdc++/89402)
  2019-02-20  8:07 [committed] Fix -Wmissing-attributes warning in libstdc++ (PR libstdc++/89402) Jakub Jelinek
@ 2019-02-22  1:19 ` Jonathan Wakely
  2019-02-22  1:47   ` Jakub Jelinek
  2019-02-22 16:09   ` Martin Sebor
  0 siblings, 2 replies; 7+ messages in thread
From: Jonathan Wakely @ 2019-02-22  1:19 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, libstdc++

On 20/02/19 09:07 +0100, Jakub Jelinek wrote:
>Hi!
>
>The following patch fixes a warning when building on targets where long
>double switched from being the same as double to something wider,
>like e.g. powerpc*-linux, alpha*-linux, s390*-linux etc.
>
>Fixed thusly, bootstrapped/regtested on {x86_64,i686,s390x}-linux and
>bootstrapped on powerpc64le-linux, on both s390x and powerpc64le it removed
>all
>../../../../libstdc++-v3/src/c++98/compatibility-ldbl.cc:77:17: warning: 'void _ZNKSt4hashIeEclEe()' specifies less restrictive attribute than its target 'std::size_t std::tr1::hash<_Tp>::operator()(_Tp) const [with _Tp = long double]': 'pure' [-Wmissing-attributes]
>warnings from the build log.  Preapproved by Jonathan in the PR, committed
>to trunk.

Now I see:

/home/jwakely/src/gcc/libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65: warning: ‘pure’ attribute on function returning ‘void’ [-Wattributes]
   78 |   _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
      |                                                                 ^

We can disable that with a diagnostic pragma.



>2019-02-20  Jakub Jelinek  <jakub@redhat.com>
>
>	PR libstdc++/89402
>	* src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Add
>	_GLIBCXX_PURE to the alias declaration.
>
>--- libstdc++-v3/src/c++98/compatibility-ldbl.cc.jj	2019-01-01 12:39:41.530606161 +0100
>+++ libstdc++-v3/src/c++98/compatibility-ldbl.cc	2019-02-19 16:12:52.402123217 +0100
>@@ -75,6 +75,6 @@ namespace std _GLIBCXX_VISIBILITY(defaul
> // and std::hash<long double>::operator()
> // are the same, no need to duplicate them.
> extern "C" void _ZNKSt4hashIeEclEe (void)
>-  __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>+  _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>
> #endif
>
>
>	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [committed] Fix -Wmissing-attributes warning in libstdc++ (PR libstdc++/89402)
  2019-02-22  1:47   ` Jakub Jelinek
@ 2019-02-22  1:47     ` Jonathan Wakely
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Wakely @ 2019-02-22  1:47 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, libstdc++

On 22/02/19 02:23 +0100, Jakub Jelinek wrote:
>On Fri, Feb 22, 2019 at 01:10:32AM +0000, Jonathan Wakely wrote:
>> On 20/02/19 09:07 +0100, Jakub Jelinek wrote:
>> > Hi!
>> >
>> > The following patch fixes a warning when building on targets where long
>> > double switched from being the same as double to something wider,
>> > like e.g. powerpc*-linux, alpha*-linux, s390*-linux etc.
>> >
>> > Fixed thusly, bootstrapped/regtested on {x86_64,i686,s390x}-linux and
>> > bootstrapped on powerpc64le-linux, on both s390x and powerpc64le it removed
>> > all
>> > ../../../../libstdc++-v3/src/c++98/compatibility-ldbl.cc:77:17: warning: 'void _ZNKSt4hashIeEclEe()' specifies less restrictive attribute than its target 'std::size_t std::tr1::hash<_Tp>::operator()(_Tp) const [with _Tp = long double]': 'pure' [-Wmissing-attributes]
>> > warnings from the build log.  Preapproved by Jonathan in the PR, committed
>> > to trunk.
>>
>> Now I see:
>>
>> /home/jwakely/src/gcc/libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65: warning: ‘pure’ attribute on function returning ‘void’ [-Wattributes]
>>   78 |   _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>>      |                                                                 ^
>>
>> We can disable that with a diagnostic pragma.
>
>Oops, sorry, missed that.
>Or make it extern "C" size_t _ZNKSt4hashIeEclEe (long double) or so, after all,
>that is what it returns and what it takes as an argument.

Ah yes, even better.

>> > 2019-02-20  Jakub Jelinek  <jakub@redhat.com>
>> >
>> > 	PR libstdc++/89402
>> > 	* src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Add
>> > 	_GLIBCXX_PURE to the alias declaration.
>> >
>> > --- libstdc++-v3/src/c++98/compatibility-ldbl.cc.jj	2019-01-01 12:39:41.530606161 +0100
>> > +++ libstdc++-v3/src/c++98/compatibility-ldbl.cc	2019-02-19 16:12:52.402123217 +0100
>> > @@ -75,6 +75,6 @@ namespace std _GLIBCXX_VISIBILITY(defaul
>> > // and std::hash<long double>::operator()
>> > // are the same, no need to duplicate them.
>> > extern "C" void _ZNKSt4hashIeEclEe (void)
>> > -  __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>> > +  _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>> >
>> > #endif
>
>	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [committed] Fix -Wmissing-attributes warning in libstdc++ (PR libstdc++/89402)
  2019-02-22  1:19 ` Jonathan Wakely
@ 2019-02-22  1:47   ` Jakub Jelinek
  2019-02-22  1:47     ` Jonathan Wakely
  2019-02-22 16:09   ` Martin Sebor
  1 sibling, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2019-02-22  1:47 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-patches, libstdc++

On Fri, Feb 22, 2019 at 01:10:32AM +0000, Jonathan Wakely wrote:
> On 20/02/19 09:07 +0100, Jakub Jelinek wrote:
> > Hi!
> > 
> > The following patch fixes a warning when building on targets where long
> > double switched from being the same as double to something wider,
> > like e.g. powerpc*-linux, alpha*-linux, s390*-linux etc.
> > 
> > Fixed thusly, bootstrapped/regtested on {x86_64,i686,s390x}-linux and
> > bootstrapped on powerpc64le-linux, on both s390x and powerpc64le it removed
> > all
> > ../../../../libstdc++-v3/src/c++98/compatibility-ldbl.cc:77:17: warning: 'void _ZNKSt4hashIeEclEe()' specifies less restrictive attribute than its target 'std::size_t std::tr1::hash<_Tp>::operator()(_Tp) const [with _Tp = long double]': 'pure' [-Wmissing-attributes]
> > warnings from the build log.  Preapproved by Jonathan in the PR, committed
> > to trunk.
> 
> Now I see:
> 
> /home/jwakely/src/gcc/libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65: warning: ‘pure’ attribute on function returning ‘void’ [-Wattributes]
>   78 |   _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>      |                                                                 ^
> 
> We can disable that with a diagnostic pragma.

Oops, sorry, missed that.
Or make it extern "C" size_t _ZNKSt4hashIeEclEe (long double) or so, after all,
that is what it returns and what it takes as an argument.

> > 2019-02-20  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	PR libstdc++/89402
> > 	* src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Add
> > 	_GLIBCXX_PURE to the alias declaration.
> > 
> > --- libstdc++-v3/src/c++98/compatibility-ldbl.cc.jj	2019-01-01 12:39:41.530606161 +0100
> > +++ libstdc++-v3/src/c++98/compatibility-ldbl.cc	2019-02-19 16:12:52.402123217 +0100
> > @@ -75,6 +75,6 @@ namespace std _GLIBCXX_VISIBILITY(defaul
> > // and std::hash<long double>::operator()
> > // are the same, no need to duplicate them.
> > extern "C" void _ZNKSt4hashIeEclEe (void)
> > -  __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
> > +  _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
> > 
> > #endif

	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [committed] Fix -Wmissing-attributes warning in libstdc++ (PR libstdc++/89402)
  2019-02-22  1:19 ` Jonathan Wakely
  2019-02-22  1:47   ` Jakub Jelinek
@ 2019-02-22 16:09   ` Martin Sebor
  2019-02-22 19:19     ` [PATCH] Fix -Wattributes " Jakub Jelinek
  1 sibling, 1 reply; 7+ messages in thread
From: Martin Sebor @ 2019-02-22 16:09 UTC (permalink / raw)
  To: Jonathan Wakely, Jakub Jelinek; +Cc: gcc-patches, libstdc++

On 2/21/19 6:10 PM, Jonathan Wakely wrote:
> On 20/02/19 09:07 +0100, Jakub Jelinek wrote:
>> Hi!
>>
>> The following patch fixes a warning when building on targets where long
>> double switched from being the same as double to something wider,
>> like e.g. powerpc*-linux, alpha*-linux, s390*-linux etc.
>>
>> Fixed thusly, bootstrapped/regtested on {x86_64,i686,s390x}-linux and
>> bootstrapped on powerpc64le-linux, on both s390x and powerpc64le it 
>> removed
>> all
>> ../../../../libstdc++-v3/src/c++98/compatibility-ldbl.cc:77:17: 
>> warning: 'void _ZNKSt4hashIeEclEe()' specifies less restrictive 
>> attribute than its target 'std::size_t 
>> std::tr1::hash<_Tp>::operator()(_Tp) const [with _Tp = long double]': 
>> 'pure' [-Wmissing-attributes]
>> warnings from the build log.  Preapproved by Jonathan in the PR, 
>> committed
>> to trunk.
> 
> Now I see:
> 
> /home/jwakely/src/gcc/libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65: warning: 
> ‘pure’ attribute on function returning ‘void’ [-Wattributes]
>    78 |   _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>       |                                                                 ^

Are the attributes on this alias ever considered in calls to it?
If not (and assuming there's a way to tell, which I think there
should be but haven't verified it) the warning could be relaxed
to only trigger for those that are.  I think those would be
either aliases declared in headers, or those with the TREE_USED
bit set.

Martin

> 
> We can disable that with a diagnostic pragma.
> 
> 
> 
>> 2019-02-20  Jakub Jelinek  <jakub@redhat.com>
>>
>>     PR libstdc++/89402
>>     * src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Add
>>     _GLIBCXX_PURE to the alias declaration.
>>
>> --- libstdc++-v3/src/c++98/compatibility-ldbl.cc.jj    2019-01-01 
>> 12:39:41.530606161 +0100
>> +++ libstdc++-v3/src/c++98/compatibility-ldbl.cc    2019-02-19 
>> 16:12:52.402123217 +0100
>> @@ -75,6 +75,6 @@ namespace std _GLIBCXX_VISIBILITY(defaul
>> // and std::hash<long double>::operator()
>> // are the same, no need to duplicate them.
>> extern "C" void _ZNKSt4hashIeEclEe (void)
>> -  __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>> +  _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
>>
>> #endif
>>
>>
>>     Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Fix -Wattributes warning in libstdc++ (PR libstdc++/89402)
  2019-02-22 16:09   ` Martin Sebor
@ 2019-02-22 19:19     ` Jakub Jelinek
  2019-02-22 19:19       ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2019-02-22 19:19 UTC (permalink / raw)
  To: Jonathan Wakely, Martin Sebor; +Cc: gcc-patches, libstdc++

On Fri, Feb 22, 2019 at 08:35:25AM -0700, Martin Sebor wrote:
> > /home/jwakely/src/gcc/libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65:
> > warning: ‘pure’ attribute on function returning ‘void’ [-Wattributes]
> >    78 |   _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
> >       |                                                                 ^
> 
> Are the attributes on this alias ever considered in calls to it?
> If not (and assuming there's a way to tell, which I think there
> should be but haven't verified it) the warning could be relaxed

There is no point in relating this, this alias is just a hack in a hack
to save a few bytes of code.

I've now finally bootstrapped/regtested on {powerpc64le,s390x}-linux
following patch, without it I indeed get those
../../../../libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65: warning: 'pure' attribute on function returning 'void' [-Wattributes]
warnings, with the patch I don't get any warnings on compatibility-ldbl.cc
anymore.  Ok for trunk?

2019-02-22  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/89402
	* src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Change return
	type to std::size_t and argument to type to long double.

--- libstdc++-v3/src/c++98/compatibility-ldbl.cc.jj	2019-02-20 08:57:18.161103140 +0100
+++ libstdc++-v3/src/c++98/compatibility-ldbl.cc	2019-02-22 09:17:54.619348391 +0100
@@ -74,7 +74,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul
 // std::tr1::hash<long double>::operator()
 // and std::hash<long double>::operator()
 // are the same, no need to duplicate them.
-extern "C" void _ZNKSt4hashIeEclEe (void)
+extern "C" std::size_t _ZNKSt4hashIeEclEe (long double)
   _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
 
 #endif


	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Fix -Wattributes warning in libstdc++ (PR libstdc++/89402)
  2019-02-22 19:19     ` [PATCH] Fix -Wattributes " Jakub Jelinek
@ 2019-02-22 19:19       ` Jonathan Wakely
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Wakely @ 2019-02-22 19:19 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jonathan Wakely, Martin Sebor, gcc-patches, libstdc++

On Fri, 22 Feb 2019 at 18:47, Jakub Jelinek wrote:
>
> On Fri, Feb 22, 2019 at 08:35:25AM -0700, Martin Sebor wrote:
> > > /home/jwakely/src/gcc/libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65:
> > > warning: ‘pure’ attribute on function returning ‘void’ [-Wattributes]
> > >    78 |   _GLIBCXX_PURE __attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
> > >       |                                                                 ^
> >
> > Are the attributes on this alias ever considered in calls to it?
> > If not (and assuming there's a way to tell, which I think there
> > should be but haven't verified it) the warning could be relaxed
>
> There is no point in relating this, this alias is just a hack in a hack
> to save a few bytes of code.
>
> I've now finally bootstrapped/regtested on {powerpc64le,s390x}-linux
> following patch, without it I indeed get those
> ../../../../libstdc++-v3/src/c++98/compatibility-ldbl.cc:78:65: warning: 'pure' attribute on function returning 'void' [-Wattributes]
> warnings, with the patch I don't get any warnings on compatibility-ldbl.cc
> anymore.  Ok for trunk?

OK, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-02-22 19:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20  8:07 [committed] Fix -Wmissing-attributes warning in libstdc++ (PR libstdc++/89402) Jakub Jelinek
2019-02-22  1:19 ` Jonathan Wakely
2019-02-22  1:47   ` Jakub Jelinek
2019-02-22  1:47     ` Jonathan Wakely
2019-02-22 16:09   ` Martin Sebor
2019-02-22 19:19     ` [PATCH] Fix -Wattributes " Jakub Jelinek
2019-02-22 19:19       ` Jonathan Wakely

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).