r337017 - Fix PR34668 - P0704R1 implementation is too permissive
Nicolas Lesser via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 13 09:27:45 PDT 2018
Author: rakete1111
Date: Fri Jul 13 09:27:45 2018
New Revision: 337017
URL: http://llvm.org/viewvc/llvm-project?rev=337017&view=rev
Log:
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
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=337017&r1=337016&r2=337017&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jul 13 09:27:45 2018
@@ -5472,8 +5472,9 @@ QualType Sema::CheckPointerToMemberOpera
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);
Modified: cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp?rev=337017&r1=337016&r2=337017&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp Fri Jul 13 09:27:45 2018
@@ -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}}
}
More information about the cfe-commits
mailing list