]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix attributes with lambda and trailing return type.
authorJason Merrill <jason@redhat.com>
Mon, 2 Mar 2020 19:42:47 +0000 (14:42 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 2 Mar 2020 20:49:57 +0000 (15:49 -0500)
commit166c024a1969ca9e77ed450fb65ce5c926a315dc
tree8e38596d3b91c21f116019cd5ef830ede6edc385
parentcb54729240b30f187a143e5e84193f5bb5029a40
c++: Fix attributes with lambda and trailing return type.

My fix for 60503 fixed handling of C++11 attributes following the
lambda-declarator.  My patch for 89640 re-added support for GNU attributes,
but attributes after the trailing return type were parsed as applying to the
return type rather than to the function.  This patch adjusts parsing of a
trailing-return-type to ignore GNU attributes at the end of the declaration
so that they will be applied to the declaration as a whole.

I also considered parsing the attributes between the closing paren and the
trailing-return-type, and tried a variety of approaches to implementing
that, but I think it's better to stick with the documented rule that "An
attribute specifier list may appear immediately before the comma, '=' or
semicolon terminating the declaration of an identifier...."  Anyone
disagree?

Meanwhile, C++ committee discussion about the lack of any way to apply
attributes to a lambda op() seems to have concluded that they should go
between the introducer and declarator, so I've implemented that as well.

gcc/cp/ChangeLog
2020-03-02  Jason Merrill  <jason@redhat.com>

PR c++/90333
PR c++/89640
PR c++/60503
* parser.c (cp_parser_type_specifier_seq): Don't parse attributes in
a trailing return type.
(cp_parser_lambda_declarator_opt): Parse C++11 attributes before
parens.
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/ext/attr-trailing1.C [new file with mode: 0644]