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


Hi Craig,

: If never warning about naked functions is truly a property of
: naked functions, I think my above suggestion is probably the best
: approach for now, though in the long run naked functions should
: probably be supported by all targets (or, perhaps, tossed
: altogether). 

OK how about this version ?  I have renamed the macro to
NAKED_FUNCTION_P and updated the description in tm.texi:

Thu Mar 18 16:10:11 1999  Nick Clifton  <nickc@cygnus.com>

	* c-decl.c (finish_function): Check NAKED_FUNCTION_P
	(if defined) before generating a warning message about a
	non-void function not returning a value.

	* tm.texi (NAKED_FUNCTION_P): Docuemnt.

	* config/arm/arm.h (NAKED_FUNCTION_P): Define.

Index: c-decl.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/c-decl.c,v
retrieving revision 1.223
diff -p -w -r1.223 c-decl.c
*** c-decl.c	1999/01/15 07:57:14	1.223
--- c-decl.c	1999/03/19 22:50:49
*************** finish_function (nested)
*** 7285,7290 ****
--- 7285,7293 ----
    if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null)
      warning ("`noreturn' function does return");
    else if (warn_return_type && can_reach_end
+ #ifdef NAKED_FUNCTION_P
+ 	   && ! NAKED_FUNCTION_P (fndecl)
+ #endif
  	   && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl))) != void_type_node)
      /* If this function returns non-void and control can drop through,
         complain.  */

Index: tm.texi
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/tm.texi,v
retrieving revision 1.147
diff -p -w -r1.147 tm.texi
*** tm.texi	1999/03/17 20:27:45	1.147
--- tm.texi	1999/03/19 22:51:02
*************** in the system math library, or @samp{""}
*** 7689,7692 ****
--- 7689,7701 ----
  separate math library.
  
  You need only define this macro if the default of @samp{"-lm"} is wrong.
+ 
+ @findex NAKED_FUNCTION_P
+ @item NAKED_FUNCTION_P (@var{decl})
+ Define this macro to return non-zero if the given function @var{decl} is
+ a naked function.  Definition of this macro is only necessary if the
+ target supports naked functions.  Naked functions are ones where the
+ function's prologue and epilogue are provided by the programmer and not
+ generated by the compiler.
+ 
  @end table

Index: config/arm/arm.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/arm/arm.h,v
retrieving revision 1.80
diff -p -w -r1.80 arm.h
*** arm.h	1999/03/17 22:48:48	1.80
--- arm.h	1999/03/19 22:52:25
*************** extern int arm_is_6_or_7;
*** 476,481 ****
--- 476,483 ----
  
  #define OVERRIDE_OPTIONS  arm_override_options ()
  
+ #define NAKED_FUNCTION_P(DECL) arm_naked_function_p (DECL)
+ 
  /* Target machine storage Layout.  */



: I do wonder, though, whether an `asm' construct or similar that
: explicitly says "return whatever is already prepared" would be
: a better approach, e.g. `return __asm__();' or some such thing.
: I don't know enough about gcc's asm facility to be sure, but,
: in general, I can see the need for such a construct.

Or maybe just the ability to mark an asm as generating a return value,
say by using an attribute.  eg:

    asm ("ldr r0, #0" ::: "r0") __attribute__((return));

Cheers
	Nick


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