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] Fix PR c/14411


Alexey Neyman <alex.neyman@auriga.ru> writes:

> This patch allows one to mark a function as setjmp-like/longjmp-like 
> with attributes setjmp/longjmp, respectively.
>
> Comments from jsm@polyomino.org.uk (oddly enough, captured in PR
> c/18180) addressed, except that I did not rename the attribute to
> "returns_twice". Having the name __attribute__((setjmp)) is
> consistent with other attributes named after a common function, e.g.
> __attribute__((malloc)).

I think I'm with Joseph on this - it should be "returns_twice" because
then it makes sense to apply the attribute to other functions with the
same property, that don't necessarily have setjmp's other behavior;
vfork() is an example.

>         if (DECL_IS_MALLOC (exp))
>   	flags |= ECF_MALLOC;
>   
> +       /* The function exp may have the `setjmp' attribute.  */
> +       if (DECL_P (exp) && DECL_IS_SETJMP (exp))
> + 	flags |= ECF_RETURNS_TWICE;
> + 
> +       /* The function exp may have the `longjmp' attribute.  */
> +       if (DECL_P (exp) && DECL_IS_LONGJMP (exp))
> + 	flags |= ECF_LONGJMP;

Given the DECL_IS_MALLOC check immediately above, the conditionals you
have added do not need DECL_P.

> + @item longjmp
> + @cindex @code{longjmp} attribute
> + The @code{longjmp} attribute tells the compiler that a function is a
> + counterpart of the respective @code{setjmp}-like function.

This isn't a good description of the attribute.  I don't know why this
is different from noreturn, so I can't suggest a better description.

The patch otherwise looks good.  Do you have a copyright assignment on
file with the FSF?

zw


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