[PATCH] D95409: [clang] implicitly delete space ship operator with function pointers
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 25 16:32:37 PST 2021
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95409.319162.patch
Type: text/x-patch
Size: 664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210126/a3a5b2ec/attachment.bin>
More information about the cfe-commits
mailing list