On Tue, 13 May 2025, Qing Zhao wrote:

> +  /* This attribute cannot be applied to a pointer type whose pointee type
> +     is void.  */
> +  else if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
> +        && TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) == VOID_TYPE)
> +    {
> +      error_at (DECL_SOURCE_LOCATION (decl),
> +             "%qE attribute is not allowed for a pointer field"
> +             " with void pointee type", name);
> +      *no_add_attrs = true;
> +    }

I think it should also be disallowed for a pointer to function, since the 
number of elements of the array makes no sense in that case.  (This will 
need test and documentation updates as well.)

However, I think it should be allowed for a pointer to non-void incomplete 
types (incomplete structure or union); in that case, the type would need 
to be completed in the context where a dereference occurs.  Since that's 
already supported in the code, there should probably be tests added for 
that case.

I think saying "pointer to void" is better than "pointer field with void 
pointee type".

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to