diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-10-06 17:43:17 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-10-06 17:43:17 +0200 |
commit | 681f18d19b56527329fc80e5fdb8ef534978f705 (patch) | |
tree | 71e727a3bf21f1fd4ae970fa2bd0c7eb48d4158b /gcc/cp | |
parent | 9bc3f4206615c69934344ea3681f9446bdc1a1f5 (diff) | |
download | gcc-681f18d19b56527329fc80e5fdb8ef534978f705.zip gcc-681f18d19b56527329fc80e5fdb8ef534978f705.tar.gz gcc-681f18d19b56527329fc80e5fdb8ef534978f705.tar.bz2 |
P0704R1 - fixing const-qualified pointers to members
P0704R1 - fixing const-qualified pointers to members
* typeck2.c (build_m_component_ref): For -std=c++2a allow
pointer to const & qualified method on rvalue.
* g++.dg/cpp2a/ptrmem1.C: New test.
From-SVN: r253494
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7292fee..e41576d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-10-06 Jakub Jelinek <jakub@redhat.com> + + P0704R1 - fixing const-qualified pointers to members + * typeck2.c (build_m_component_ref): For -std=c++2a allow + pointer to const & qualified method on rvalue. + 2017-10-06 Nathan Sidwell <nathan@acm.org> Use hash_table for extern "C" names diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 82e18ec..39bc97a 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1908,9 +1908,10 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) { /* 5.5/6: In a .* expression whose object expression is an rvalue, the program is ill-formed if the second operand is a pointer to member - function with ref-qualifier &. In a .* expression whose object - expression is an lvalue, the program is ill-formed if the second - operand is a pointer to member function with ref-qualifier &&. */ + function with ref-qualifier & (for C++2A: unless its cv-qualifier-seq + is const). In a .* expression whose object expression is an lvalue, + the program is ill-formed if the second operand is a pointer to member + function with ref-qualifier &&. */ if (FUNCTION_REF_QUALIFIED (type)) { bool lval = lvalue_p (datum); @@ -1921,7 +1922,12 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) ptrmem_type); return error_mark_node; } - else if (!lval && !FUNCTION_RVALUE_QUALIFIED (type)) + else if (!lval + && !FUNCTION_RVALUE_QUALIFIED (type) + && (cxx_dialect < cxx2a + || ((type_memfn_quals (type) + & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)) + != TYPE_QUAL_CONST))) { if (complain & tf_error) error ("pointer-to-member-function type %qT requires an lvalue", |