On Mon, Aug 17, 2020 at 05:08:41PM +0100, Daniel P. Berrangé wrote:
> On Thu, Aug 13, 2020 at 06:26:14PM -0400, Eduardo Habkost wrote:
> > The existing type check macros all unconditionally drop const
> > qualifiers from their arguments. Keep this behavior in the
> > macros generated by DECLARE_*CHECKER* by now.
> >
> > In the future, we might use _Generic to preserve const-ness of
> > the cast function arguments.
>
> I'm not sure what you mean by "use _Generic" ?
I meant something like:
#define OBJECT_CHECK(Type, obj, ...) \
_Generic((obj),
void *: (Type *)object_dynamic_cast_assert(obj, ...),
const void *: (const Type *)object_dynamic_cast_assert(obj,
...))
However, now we'll generate type checking functions instead of
type checking macros, so making (for example) DEVICE((Object*)x)
and DEVICE((const Object*)x) return a different type would be
impossible.
--
Eduardo