[PATCH] D104892: [clang] Stop providing builtin overload candidate for relational function pointer comparisons

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 24 18:53:16 PDT 2021


mizvekov created this revision.
mizvekov requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

Word on the grapevine was that the committee had some discussion that
ended with unanimous agreement on eliminating relational function pointer comparisons.

We wanted to be bold and just ban all of them cold turkey.
But then we chickened out at the last second and are going for
eliminating just the spaceship overload candidate instead, for now.

See D104680 <https://reviews.llvm.org/D104680> for reference.

This should be fine and "safe", because the only possible semantic change this
would cause is that overload resoltion could possibly be ambiguous if
there was another viable candidate equally as good.

But to save face a little we are going to:

- Issue an "error" for three-way comparisons on function pointers. But all this is doing really is changing one vague error message, from an "invalid operands to binary expression" into an "ordered comparison of function pointers", which sounds more like we mean business.
- Otherwise "warn" that comparing function pointers like that is totally not cool (unless we are told to keep quiet about this).
- Treat them all as errors with '-pedantic-errors'.

Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104892

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
  clang/test/CXX/drs/dr15xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/FixIt/fixit.cpp
  clang/test/Parser/cxx-template-argument.cpp
  clang/test/Sema/compare.c
  clang/test/SemaCXX/compare-cxx2a.cpp
  clang/test/SemaCXX/compare-function-pointer.cpp
  clang/test/SemaTemplate/resolve-single-template-id.cpp
  compiler-rt/test/asan/TestCases/Posix/coverage-module-unloaded.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104892.354414.patch
Type: text/x-patch
Size: 20147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210625/47466292/attachment-0001.bin>


More information about the cfe-commits mailing list