public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Martin Uecker <uecker@tugraz.at>, gcc-patches@gcc.gnu.org
Cc: Joseph Myers <joseph@codesourcery.com>, jakub Jelinek <jakub@redhat.com>
Subject: Re: [PING 2] [C PATCH] Synthesize nonnull attribute for parameters declared with static
Date: Fri, 10 Nov 2023 13:43:27 -0700	[thread overview]
Message-ID: <9b97edba-36b3-48b5-a5df-047b2ac41d2e@gmail.com> (raw)
In-Reply-To: <564177ba373bb73cfc2c2b106b7e57b4bcbc512e.camel@tugraz.at>



On 10/21/23 05:09, Martin Uecker wrote:
>>
>> C programmers increasingly use static to indicate that
>> pointer parameters are non-null.  Clang can exploit this
>> for warnings and optimizations.  GCC has some warnings
>> but not all warnings it has for nonnull.  Below is a
>> patch to add a nonnull attribute automatically for such
>> arguments and to remove the special and more limited
>> nonnull warnings for static. This patch found some
>> misplaced annotations in one of my projects via
>> -Wnonnull-compare which clang does not seem to have,
>> so I think this could be useful.
> 
>      c: Synthesize nonnull attribute for parameters declared with static [PR110815]
>      
>      Parameters declared with `static` are nonnull. We synthesize
>      an artifical nonnull attribute for such parameters to get the
>      same warnings and optimizations.
>      
>      Bootstrapped and regression tested on x86.
>      
> 	    PR c/102558
> 	    PR 102556
>              PR c/110815
>      
>      gcc/c-family:
>              * c-attribs.cc (build_attr_access_from_parms): Synthesize
>              nonnull attribute for parameters declared with `static`.
>      
>      gcc:
>              * gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes):
>              remove warning for parameters declared with `static`.
>      
>      gcc/testsuite:
>              * gcc.dg/Wnonnull-8.c: Adapt test.
>              * gcc.dg/Wnonnull-9.c: New test.
This is OK -- assuming you did the usual bootstrap & regression test 
cycle.

Jeff

      reply	other threads:[~2023-11-10 20:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-26 16:06 Martin Uecker
2023-09-24 13:13 ` [PING] " Martin Uecker
2023-10-21 11:09 ` [PING 2] " Martin Uecker
2023-11-10 20:43   ` Jeff Law [this message]

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=9b97edba-36b3-48b5-a5df-047b2ac41d2e@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=uecker@tugraz.at \
    /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).