[clang] Bug 17456 cast diagnostic

Nathan Sidwell nathan at acm.org
Tue Jan 27 15:35:41 PST 2015


On 01/23/15 16:49, Richard Smith wrote:

>
> How about "static_cast from 'A *' to type 'B *' that is not related by
> inheritance is not allowed"? As it stands, it sounds like you're
> calling the type 'B *' a hierarchy. Also, consider:

Yeah, I was struggling with suitable  wording.  This version goes with:
  ... from %1 to %2, which are unrelated by inheritance, is not allowed

> While here, please give err_bad_cxx_cast_unrelated a slightly more
> specific name; [...]unrelated_class or similar?

Done.

> I think we should only do this if we're casting to and from a class
> type; I don't think it's useful to point out that T is an incomplete
> type in:

Done.

> Also, we should produce a similar "unrelated hierarchy" diagnostic and
> "incomplete" note when casting to a reference to incomplete class type
> or casting from an lvalue of incomplete class type.

Not disagreeing.  Can we handle this in a different patch?

>
> Finally, trivial formatting things:
>   * remove the space before the parens in the function calls above.

Done.  It's going to take a while to retrain my fingers.

>   * put the && on the previous line when it's used in a line continuation:
>
> +      if (SrcPointer->getPointeeType()->getAs<RecordType>()
> +          && DestPointer->getPointeeType()->getAs<RecordType>())

Done.  (inconsistent with how << is formatted, but what the hey)

ok?

nathan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 17456-3.patch
Type: text/x-patch
Size: 5774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150127/370dd975/attachment.bin>


More information about the cfe-commits mailing list