[clang] [bug 17456] cast diagnostic
Nathan Sidwell
nathan at acm.org
Thu Dec 11 12:06:27 PST 2014
Ping?
On 12/03/14 16:51, Nathan Sidwell wrote:
> This patch addresses 17456, which is a desire for failed casts involving
> classes to give better diagnostic. see http://llvm.org/bugs/show_bug.cgi?id=17456
>
> Rather than a plain 'cannot cast' error, this patch changes things to:
>
> 1) for static cast from 'A *' to 'B *' where T & S are classes, give
> 'static_cast from 'A *' to unrelated type 'B *' is not allowed'
>
> 2) where a cast fails and involves incomplete classes (directly or as a
> pointer), it also notes that the class is incomplete. For instance:
>
> 17456.cc:6:10: error: static_cast from 'A *' to unrelated type 'B *' is not allowed
> return static_cast<B*>(arg);
> ^~~~~~~~~~~~~~~~~~~~
> 17456.cc:3:8: note: 'B' is incomplete
> struct B;
>
>
> The test suite already had applicable cases, so this patch just adjusts those
> tests.
>
> Perhaps the incomplete note should be broken out into a general utility
> function? And perhaps unconditionally show the location of the class
> definition/declaration, as that's probably useful in figuring out how to fix the
> problem?
>
> guidance welcome.
>
> nathan
More information about the cfe-commits
mailing list