mizvekov created this revision. Herald added a subscriber: yaxunl. mizvekov requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
See bug #48856 Definitions of classes with member function pointers and default spaceship operator were getting accepted with no diagnostic on release build, and triggering assert on builds with runtime checks enabled. Diagnostics were only produced when actually comparing instances of such classes. This patch makes it so Spaceship and Less operators are not considered as builtin operator candidates for function pointers, producing equivalent diagnostics for the cases where pointers to member function and pointers to data members are used instead. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D95409 Files: clang/lib/Sema/SemaDeclCXX.cpp Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -7677,7 +7677,8 @@ if (Args[0]->getType()->isOverloadableType()) S.LookupOverloadedBinOp(CandidateSet, OO, Fns, Args); - else { + else if (OO == OO_EqualEqual || + !Args[0]->getType()->isFunctionPointerType()) { // FIXME: We determine whether this is a valid expression by checking to // see if there's a viable builtin operator candidate for it. That isn't // really what the rules ask us to do, but should give the right results.
Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -7677,7 +7677,8 @@ if (Args[0]->getType()->isOverloadableType()) S.LookupOverloadedBinOp(CandidateSet, OO, Fns, Args); - else { + else if (OO == OO_EqualEqual || + !Args[0]->getType()->isFunctionPointerType()) { // FIXME: We determine whether this is a valid expression by checking to // see if there's a viable builtin operator candidate for it. That isn't // really what the rules ask us to do, but should give the right results.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits