P0704R1 - fixing const-qualified pointers to members
* typeck2.c (build_m_component_ref): Also accept in lower stds with a pedwarn. From-SVN: r254487
This commit is contained in:
parent
2d041117f1
commit
96d155c696
|
@ -1,3 +1,9 @@
|
|||
2017-11-06 Jason Merrill <jason@redhat.com>
|
||||
|
||||
P0704R1 - fixing const-qualified pointers to members
|
||||
* typeck2.c (build_m_component_ref): Also accept in lower stds with
|
||||
a pedwarn.
|
||||
|
||||
2017-11-06 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/65579
|
||||
|
|
|
@ -1922,18 +1922,27 @@ 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)
|
||||
&& (cxx_dialect < cxx2a
|
||||
|| ((type_memfn_quals (type)
|
||||
else if (!lval && !FUNCTION_RVALUE_QUALIFIED (type))
|
||||
{
|
||||
if ((type_memfn_quals (type)
|
||||
& (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))
|
||||
!= TYPE_QUAL_CONST)))
|
||||
!= TYPE_QUAL_CONST)
|
||||
{
|
||||
if (complain & tf_error)
|
||||
error ("pointer-to-member-function type %qT requires an lvalue",
|
||||
ptrmem_type);
|
||||
error ("pointer-to-member-function type %qT requires "
|
||||
"an lvalue", ptrmem_type);
|
||||
return error_mark_node;
|
||||
}
|
||||
else if (cxx_dialect < cxx2a)
|
||||
{
|
||||
if (complain & tf_warning_or_error)
|
||||
pedwarn (input_location, OPT_Wpedantic,
|
||||
"pointer-to-member-function type %qT requires "
|
||||
"an lvalue before C++2a", ptrmem_type);
|
||||
else
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
return build2 (OFFSET_REF, type, datum, component);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// P0704R1
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "" }
|
||||
|
||||
struct S {
|
||||
void ref() & {}
|
||||
void cref() const& {}
|
||||
void vref() volatile & {}
|
||||
void cvref() const volatile & {}
|
||||
};
|
||||
|
||||
void
|
||||
foo ()
|
||||
{
|
||||
S{}.ref(); // { dg-error "argument discards qualifiers" }
|
||||
S{}.cref();
|
||||
S{}.vref(); // { dg-error "argument discards qualifiers" }
|
||||
S{}.cvref(); // { dg-error "argument discards qualifiers" }
|
||||
|
||||
(S{}.*&S::ref)(); // { dg-error "pointer-to-member-function type 'void \\(S::\\*\\)\\(\\) &' requires an lvalue" }
|
||||
(S{}.*&S::cref)();
|
||||
(S{}.*&S::vref)(); // { dg-error "pointer-to-member-function type 'void \\(S::\\*\\)\\(\\) volatile &' requires an lvalue" }
|
||||
(S{}.*&S::cvref)(); // { dg-error "pointer-to-member-function type 'void \\(S::\\*\\)\\(\\) const volatile &' requires an lvalue" }
|
||||
}
|
Loading…
Reference in New Issue