public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [C PATCH] Fix up diagnostics (PR c/25801)
Date: Thu, 01 May 2014 22:54:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1405012251170.16441@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20140418202533.GN20332@redhat.com>

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

  reply	other threads:[~2014-05-01 22:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18 20:30 Marek Polacek
2014-05-01 22:54 ` Joseph S. Myers [this message]
2014-05-02  7:44   ` Marek Polacek
2014-05-02 17:51     ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.1405012251170.16441@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=polacek@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).