+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
{
/* 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);
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",
+2017-10-06 Jakub Jelinek <jakub@redhat.com>
+
+ P0704R1 - fixing const-qualified pointers to members
+ * g++.dg/cpp2a/ptrmem1.C: New test.
+
2017-10-06 Martin Liska <mliska@suse.cz>
* c-c++-common/ubsan/ptr-overflow-sanitization-1.c: New test.
--- /dev/null
+// P0704R1
+// { dg-do compile { target c++11 } }
+
+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)(); // { dg-error "pointer-to-member-function type 'void \\(S::\\*\\)\\(\\) const &' requires an lvalue" "" { target c++17_down } }
+ (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" }
+}