This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C PATCH] Fix up diagnostics (PR c/25801)


On Fri, 18 Apr 2014, Marek Polacek wrote:

> @@ -1760,15 +1760,10 @@ c_size_in_bytes (const_tree type)

I think the comment on this function should be updated to explain the 
interface contract when an incomplete (or function) type is passed (i.e. 
return size_one_node, caller is responsible for any diagnostics).

> diff --git gcc/testsuite/gcc.dg/pr25801.c gcc/testsuite/gcc.dg/pr25801.c
> index e69de29..70b4ef8 100644
> --- gcc/testsuite/gcc.dg/pr25801.c
> +++ gcc/testsuite/gcc.dg/pr25801.c
> @@ -0,0 +1,19 @@
> +/* PR c/25801 */
> +/* { dg-do compile } */
> +
> +int (*a)[];
> +struct S *s;
> +
> +void
> +f (void)
> +{
> +  a++; /* { dg-error "increment of pointer to an incomplete type" } */
> +  ++a; /* { dg-error "increment of pointer to an incomplete type" } */
> +  a--; /* { dg-error "decrement of pointer to an incomplete type" } */
> +  --a; /* { dg-error "decrement of pointer to an incomplete type" } */
> +
> +  s++; /* { dg-error "increment of pointer to an incomplete type" } */
> +  ++s; /* { dg-error "increment of pointer to an incomplete type" } */
> +  s--; /* { dg-error "decrement of pointer to an incomplete type" } */
> +  --s; /* { dg-error "decrement of pointer to an incomplete type" } */
> +}

The test should I think also cover incomplete union types, and pointer 
subtraction for all the different cases of incomplete types, and the += 
and -= operators (i.e. cover invalid arithmetic on pointers to incomplete 
types more thoroughly, even if not actually affected by this patch).

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]