Index: include/clang/Basic/DiagnosticGroups.td =================================================================== --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -169,6 +169,9 @@ def CXXPre1zCompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic", [CXXPre1zCompat]>; +// Warnings for C++2a code which is not compatible with prior C++ standards. +def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">; + def CXX98CompatBindToTemporaryCopy : DiagGroup<"c++98-compat-bind-to-temporary-copy">; def CXX98CompatLocalTypeTemplateArgs : @@ -180,7 +183,8 @@ [CXX98CompatLocalTypeTemplateArgs, CXX98CompatUnnamedTypeTemplateArgs, CXXPre14Compat, - CXXPre1zCompat]>; + CXXPre1zCompat, + CXXPre2aCompat]>; // Warnings for C++11 features which are Extensions in C++98 mode. def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic", [CXX98Compat, @@ -211,7 +215,8 @@ CXX11CompatReservedUserDefinedLiteral, CXX11CompatDeprecatedWritableStr, CXXPre14Compat, - CXXPre1zCompat]>; + CXXPre1zCompat, + CXXPre2aCompat]>; def : DiagGroup<"c++0x-compat", [CXX11Compat]>; def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic", [CXXPre14CompatPedantic, @@ -784,9 +789,14 @@ // earlier C++ versions. def CXX17 : DiagGroup<"c++17-extensions">; +// A warning group for warnings about using C++2a features as extensions in +// earlier C++ versions. +def CXX20 : DiagGroup<"c++20-extensions">; + def : DiagGroup<"c++0x-extensions", [CXX11]>; def : DiagGroup<"c++1y-extensions", [CXX14]>; def : DiagGroup<"c++1z-extensions", [CXX17]>; +def : DiagGroup<"c++2a-extensions", [CXX20]>; def DelegatingCtorCycles : DiagGroup<"delegating-ctor-cycles">; Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -4088,6 +4088,13 @@ def err_pointer_to_member_oper_value_classify: Error< "pointer-to-member function type %0 can only be called on an " "%select{rvalue|lvalue}1">; +def ext_pointer_to_const_ref_member_on_rvalue : ExtWarn< + "pointer-to-member to const& function on an rvalue is a C++2a extension">, + InGroup; +def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning< + "pointer-to-member function for const& member function on rvalues is " + "incompatible with C++ standards before C++2a">, + InGroup, DefaultIgnore; def ext_ms_deref_template_argument: ExtWarn< "non-type template argument containing a dereference operation is a " "Microsoft extension">, InGroup; Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -5175,9 +5175,16 @@ break; case RQ_LValue: - if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) - Diag(Loc, diag::err_pointer_to_member_oper_value_classify) - << RHSType << 1 << LHS.get()->getSourceRange(); + if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) { + // C++2a allows functions with ref-qualifier & if they are also 'const'. + if (Proto->isConst()) + Diag(Loc, getLangOpts().CPlusPlus2a + ? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue + : diag::ext_pointer_to_const_ref_member_on_rvalue); + else + Diag(Loc, diag::err_pointer_to_member_oper_value_classify) + << RHSType << 1 << LHS.get()->getSourceRange(); + } break; case RQ_RValue: Index: www/cxx_status.html =================================================================== --- www/cxx_status.html +++ www/cxx_status.html @@ -777,13 +777,12 @@

C++2a implementation status

-

Clang does not yet support any of the proposed features of - +

Clang has experimental support for some proposed features of the C++ standard following C++17, provisionally named C++2a. Note that support for these features may change or be removed without notice, as the draft C++2a standard evolves. - +

You can use Clang in C++2a mode with the -std=c++2a option.

List of features and minimum Clang version with support @@ -803,7 +802,7 @@ const&-qualified pointers to members P0704R1 - No + SVN Allow lambda-capture [=, this]