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: [PATCH] Avoid duplicate -Wnonnull warnings (PR c++/28656)


On Fri, Jul 20, 2012 at 11:04 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Jul 20, 2012 at 10:37:32AM +0200, Richard Guenther wrote:
>> On Thu, Jul 19, 2012 at 6:53 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> Hum.  How hard would it be to merge the attributes?
>
> IMHO hard and ugly.  The thing is that you probably can do some hacks
> easily in handle_nonnull_attribute, so that multiple nonnull attributes
> on the same prototype get merged together (at the end of function when
> returning without *no_add_attrs = true; before it, do
> a = lookup_attribute ("nonnull", TYPE_ATTRIBUTES (type));
> if (a != NULL)
>   {
>     merge stuff into a;
>     *no_add_attrs = true;
>   }
> ), but that handles just one of the cases, where multiple nonnull attributes
> appear on the same prototype.  But you can (and with builtins.def usually
> do) have also
> void foo (void *, void *, void *) __attribute__((nonnull (1)));
> void foo (void *, void *, void *) __attribute__((nonnull (2)));
> and for that case no attribute hook is called, so either merge_attributes
> would need to special case this attribute (which would be a layering
> violation, as nonnull is just C/C++ attribute), or each FE would need in its
> merge_decls and similar call lookup_attribute ("nonnull", TYPE_ATTRIBUTES (...));
> twice and do the merging manually.  As there are just two users of the
> nonnull attribute, handling all of them there looked much shorter and easier
> to me.

In the end it asks for a rewrite of the attribute representation and
handling code ...
(a unified attributes.def file and a non-string-based
non-tree-list-based storage,
etc. ...).

Your patch is ok meanwhile.

Thanks,
Richard.

>> > 2012-07-19  Jakub Jelinek  <jakub@redhat.com>
>> >
>> >         PR c++/28656
>> >         * tree-vrp.c (nonnull_arg_p): Handle all nonnull attributes instead
>> >         of just the first one.
>> >
>> >         * c-common.c (check_function_nonnull): Handle multiple nonnull
>> >         attributes properly.
>> >
>> >         * c-c++-common/pr28656.c: New test.
>
>         Jakub


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