public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
@ 2021-05-14 7:47 marxin at gcc dot gnu.org
2021-05-14 7:48 ` [Bug c++/100596] " marxin at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-14 7:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
Bug ID: 100596
Summary: [12 Regression] error: attribute appertains to a
friend declaration that is not a definition since
r12-786-g149061188c7c6ddf
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: jason at gcc dot gnu.org, mpolacek at gcc dot gnu.org
Target Milestone: ---
Affects multiple packages:
$ cat json.ii
struct final {
friend __attribute__((visibility)) bool;
};
$ g++ json.ii -c
json.ii:2:3: error: attribute appertains to a friend declaration that is not a
definition
2 | friend __attribute__((visibility)) bool;
| ^~~~~~
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100596] [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
@ 2021-05-14 7:48 ` marxin at gcc dot gnu.org
2021-05-14 12:45 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-14 7:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Target Milestone|--- |12.0
Priority|P3 |P1
Last reconfirmed| |2021-05-14
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100596] [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
2021-05-14 7:48 ` [Bug c++/100596] " marxin at gcc dot gnu.org
@ 2021-05-14 12:45 ` mpolacek at gcc dot gnu.org
2021-05-14 14:13 ` marxin at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-05-14 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Rejecting such code was the point of the patch. I guess we'll have to either
downgrade to a warning or just not complain about GNU attributes at all.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100596] [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
2021-05-14 7:48 ` [Bug c++/100596] " marxin at gcc dot gnu.org
2021-05-14 12:45 ` mpolacek at gcc dot gnu.org
@ 2021-05-14 14:13 ` marxin at gcc dot gnu.org
2021-05-14 14:33 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-14 14:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
I noticed that in a couple of packages that I have in my testing playground:
https://build.opensuse.org/project/monitor/home:marxin:home:marxin:gcc-periodic-testing-v2
[ 1268s]
/home/abuild/rpmbuild/BUILD/libreoffice-7.1.3.2/workdir/UnpackedTarball/skia/include/core/SkMatrix.h:1579:24:
error: attribute appertains to a friend declaration that is not a definition
[ 1268s] 1579 | friend SK_API bool operator==(const SkMatrix& a, const
SkMatrix& b);
[ 1268s] | ^~~~~~~~
[ 98s] /usr/include/boost/thread/detail/thread.hpp:641:37: error: attribute
appertains to a friend declaration that is not a definition
[ 98s] 641 | friend id BOOST_THREAD_DECL this_thread::get_id()
BOOST_NOEXCEPT;
[ 98s] | ^~~~~~~~~~~
[ 279s] /usr/include/qt5/QtCore/qbytearray.h:486:37: error: attribute
appertains to a friend declaration that is not a definition
[ 279s] 486 | friend Q_CORE_EXPORT QByteArray qUncompress(const uchar
*data, int nbytes);
[ 279s] | ^~~~~~~~~~~
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100596] [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
` (2 preceding siblings ...)
2021-05-14 14:13 ` marxin at gcc dot gnu.org
@ 2021-05-14 14:33 ` jason at gcc dot gnu.org
2021-05-14 17:04 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-05-14 14:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #1)
> Rejecting such code was the point of the patch. I guess we'll have to
> either downgrade to a warning or just not complain about GNU attributes at
> all.
Let's do both.
It occurs to me that attributes on non-definition friends can be useful when
there is no other reachable declaration of the function, as
struct A
{
__attribute((deprecated)) friend void f(A); // part of A API, definition in
.C
};
int main()
{
A a;
f(a); // warning desired
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100596] [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
` (3 preceding siblings ...)
2021-05-14 14:33 ` jason at gcc dot gnu.org
@ 2021-05-14 17:04 ` mpolacek at gcc dot gnu.org
2021-05-19 17:10 ` cvs-commit at gcc dot gnu.org
2021-05-19 17:13 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-05-14 17:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
On it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100596] [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
` (4 preceding siblings ...)
2021-05-14 17:04 ` mpolacek at gcc dot gnu.org
@ 2021-05-19 17:10 ` cvs-commit at gcc dot gnu.org
2021-05-19 17:13 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-19 17:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:adcb497bdba499d161d2e5e8de782bdd6f75d62c
commit r12-925-gadcb497bdba499d161d2e5e8de782bdd6f75d62c
Author: Marek Polacek <polacek@redhat.com>
Date: Tue May 18 16:11:16 2021 -0400
c++: Relax attribute on friend declaration checking [PR100596]
It turned out that there are codebases that profusely use GNU attributes
on friend declarations, so we have to dial back our checking and allow
them. And for C++11 attributes let's just warn instead of giving
errors.
PR c++/100596
gcc/cp/ChangeLog:
* cp-tree.h (any_non_type_attribute_p): Remove.
* decl.c (grokdeclarator): Turn an error into a warning and only
warn for standard attributes.
* decl2.c (any_non_type_attribute_p): Remove.
* parser.c (cp_parser_elaborated_type_specifier): Turn an error
into a warning and only warn for standard attributes.
(cp_parser_member_declaration): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/friend7.C: Turn a few dg-warnings into dg-errors.
Remove dg-errors for GNU attributes.
* g++.dg/ext/attrib63.C: Remove dg-error.
* g++.dg/cpp0x/friend8.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100596] [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
` (5 preceding siblings ...)
2021-05-19 17:10 ` cvs-commit at gcc dot gnu.org
@ 2021-05-19 17:13 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-05-19 17:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100596
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Should be fixed, sorry.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-05-19 17:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 7:47 [Bug c++/100596] New: [12 Regression] error: attribute appertains to a friend declaration that is not a definition since r12-786-g149061188c7c6ddf marxin at gcc dot gnu.org
2021-05-14 7:48 ` [Bug c++/100596] " marxin at gcc dot gnu.org
2021-05-14 12:45 ` mpolacek at gcc dot gnu.org
2021-05-14 14:13 ` marxin at gcc dot gnu.org
2021-05-14 14:33 ` jason at gcc dot gnu.org
2021-05-14 17:04 ` mpolacek at gcc dot gnu.org
2021-05-19 17:10 ` cvs-commit at gcc dot gnu.org
2021-05-19 17:13 ` mpolacek at gcc dot gnu.org
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).