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]

Re: Patch to add new target macro: TARGET_WARN_RETURN_TYPE


>  I think I may have to abandon this patch.  I have been trying to
>think of an alternative way of solving the problem, other than
>creating the NAKED_FUNCTION_P macro.  The attribute idea:
>
>  asm (<return from function call>) __attribute__((return));
>
>or the type qualifier idea:
>
>  asm return (<return from function call>);
>
>both require modifications to GCC's parser and will probably be
>rejected as even worse forms of creeping featurism.  (Besides asms are
>not supposed to alter the flow of control, so adding support for asms
>that do this is probably not going to be acceptable).

Well, I think those of us who proposed this kind of approach knew
it might be more trouble than it's worth.

>  It looks like I will have to go back to my horrible hack that solves
>the problem in the back end.  Oh well.

Okay.

However, I myself wasn't thinking in terms of a new asm that did a
return.  Rather, some kind of attribution indicating that a return
value has already been computed and put in the proper register.

Since I don't really know what the codes in question look like, I can
only guess, but let's say it's something like

  ...
  /* Set return value.  */
  asm ("ld %r0, x");  /* (remember, I don't code asm's, this is a guess). */
  ...
  /* Do the actual return.  */
  return;

The "proper" way to address this is, IMO, to "decorate" either the asm
or the return (ideally, the former) to indicate that a return value
is being set:

  ...
  /* Set return value.  */
  asm ("ld %r0, x") __attribute((sets_return_value));
  ...
  /* Do the actual return.  */
  return;

Or:

  ...
  /* Set return value.  */
  asm ("ld %r0, x");  /* (remember, I don't code asm's, this is a guess). */
  ...
  /* Do the actual return.  */
  return __attribute__((with-return-value));

Something along those lines.  (I prefer the former: it marks the place
the return value is actually set, allowing the compiler to find bugs
if asm's are moved vis-a-vis return's, leaving returns without values
possible.)

The above might be just as challenging as the things you tried.
Then again, it might be easier.

        tq vm, (burley)


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