[PATCH] D74009: [clang] Improve diagnostic note for implicit conversions that are disallowed because they involve more than one user-defined conversion.

Logan Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 4 16:23:01 PST 2020


logan-5 created this revision.
logan-5 added a reviewer: rsmith.
logan-5 added a project: clang.
Herald added a subscriber: cfe-commits.

The current text of the 'note' diagnostic for bad conversions is confusing in the presence of user-defined conversion operations: https://godbolt.org/z/zrgeHH
For the first error, the conversion function is simply pointed at in a note without any further explanation. For the second error, the final note claims there is no conversion from X2 to Y2, even though it is plainly visible in the source code. The reason for the error is that only one implicit user-defined conversion may be applied in these circumstances, but the error message is misleading to those who may not know this rule.

This patch clarifies this situation with a better diagnostic message. It does so by finding user conversions even where they are not allowed, and then discarding them afterward as invalid, but keeping a record that they existed. There is also a stronger mode (`UDC_Skip`) for skipping the search for user-defined conversions outright, which matches the old behavior and is retained to prevent infinite recursions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74009

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr0xx.cpp
  clang/test/SemaCXX/user-defined-conversions.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74009.242454.patch
Type: text/x-patch
Size: 55583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200205/05d30793/attachment-0001.bin>


More information about the cfe-commits mailing list