mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 00:56:41 +00:00
Fix PR34668 - P0704R1 implementation is too permissive
Summary: https://bugs.llvm.org/show_bug.cgi?id=34668 Pretty straightforward. Reviewers: rsmith, Rakete1111 Reviewed By: Rakete1111 Subscribers: Rakete1111, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D38075 llvm-svn: 337017
This commit is contained in:
parent
3f7d20904f
commit
1ad0e9f039
@ -5472,8 +5472,9 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS,
|
||||
|
||||
case RQ_LValue:
|
||||
if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
|
||||
// C++2a allows functions with ref-qualifier & if they are also 'const'.
|
||||
if (Proto->isConst())
|
||||
// C++2a allows functions with ref-qualifier & if their cv-qualifier-seq
|
||||
// is (exactly) 'const'.
|
||||
if (Proto->isConst() && !Proto->isVolatile())
|
||||
Diag(Loc, getLangOpts().CPlusPlus2a
|
||||
? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
|
||||
: diag::ext_pointer_to_const_ref_member_on_rvalue);
|
||||
|
@ -3,12 +3,15 @@
|
||||
struct X {
|
||||
void ref() & {} // expected-note{{'ref' declared here}}
|
||||
void cref() const& {}
|
||||
void cvref() const volatile & {} // expected-note{{'cvref' declared here}}
|
||||
};
|
||||
|
||||
void test() {
|
||||
X{}.ref(); // expected-error{{'this' argument to member function 'ref' is an rvalue, but function has non-const lvalue ref-qualifier}}
|
||||
X{}.cref(); // expected-no-error
|
||||
X{}.cvref(); // expected-error{{'this' argument to member function 'cvref' is an rvalue, but function has non-const lvalue ref-qualifier}}
|
||||
|
||||
(X{}.*&X::ref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
|
||||
(X{}.*&X::cref)(); // expected-no-error
|
||||
(X{}.*&X::cvref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user