diff options
author | Marek Polacek <polacek@redhat.com> | 2020-01-21 17:38:54 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2020-01-22 12:30:15 -0500 |
commit | e1fd040884ab7ac36ca5555ab5822bcb5e51e8d8 (patch) | |
tree | 2f923a8d3232ebc3530b978b25a2374fb1e37a92 /gcc/real.c | |
parent | 15ed55eabb0cf8a2974b8025a9f46c9e58960811 (diff) | |
download | gcc-e1fd040884ab7ac36ca5555ab5822bcb5e51e8d8.zip gcc-e1fd040884ab7ac36ca5555ab5822bcb5e51e8d8.tar.gz gcc-e1fd040884ab7ac36ca5555ab5822bcb5e51e8d8.tar.bz2 |
PR c++/92907 - noexcept does not consider "const" in member functions.
Here the problem is that if the noexcept specifier is used in the context
of a const member function, const is not considered for the member variables,
leading to a bogus error. g's const makes its 'this' const, so the first
overload of f should be selected.
In cp_parser_noexcept_specification_opt we inject 'this', but always
unqualified:
25737 if (current_class_type)
25738 inject_this_parameter (current_class_type, TYPE_UNQUALIFIED);
so we need to pass the function's qualifiers down here. In
cp_parser_direct_declarator it's easy: use the just parsed cv_quals, in
cp_parser_late_noexcept_specifier look at the 'this' parameter to figure it
out.
2020-01-22 Marek Polacek <polacek@redhat.com>
PR c++/92907 - noexcept does not consider "const" in member functions.
* parser.c (cp_parser_lambda_declarator_opt): Pass the proper
qualifiers to cp_parser_exception_specification_opt.
(cp_parser_direct_declarator): Pass the function qualifiers to
cp_parser_exception_specification_opt.
(cp_parser_class_specifier_1): Pass the function declaration to
cp_parser_late_noexcept_specifier.
(cp_parser_late_noexcept_specifier): Add a tree parameter. Use it to
pass the qualifiers of the function to
cp_parser_noexcept_specification_opt.
(cp_parser_noexcept_specification_opt): New cp_cv_quals parameter.
Use it in inject_this_parameter.
(cp_parser_exception_specification_opt): New cp_cv_quals parameter.
Use it.
(cp_parser_transaction): Pass TYPE_UNQUALIFIED to
cp_parser_noexcept_specification_opt.
(cp_parser_transaction_expression): Likewise.
* g++.dg/cpp0x/noexcept56.C: New test.
Diffstat (limited to 'gcc/real.c')
0 files changed, 0 insertions, 0 deletions