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: Possible patch for tree-optimization/13000


> 2005-01-20  Ian Lance Taylor  <ian@airs.com>
>
> 	PR tree-optimization/13000
> 	* tree-inline.c: Include "tree-flow.h".
> 	(expand_call_inline): If warn_return_type, warn if non-void inline
> 	function falls through.
> 	* tree-cfg.c (execute_warn_function_return): Don't warn about
> 	control reaching end if TREE_NO_WARNING is set.  Set
> 	TREE_NO_WARNING.
> 	* gimple-low.c (block_may_fallthru): Don't assume that SWITCH_EXPR
> 	has been lowered.
> 	* gimplify.c (shortcut_cond_expr): Don't emit a jump over the else
> 	branch if we don't need one.
> 	* c-typeck.c: Include "tree-flow.h"
> 	(c_finish_bc_stmt): Don't add a goto if the current statement
> 	list doesn't fall through to the current point.

This breaks Ada (PR middle-end/19600).

For these lines in make.adb:Scan_Make_Arg:

      elsif Argv = "-bargs"
              or else
            Argv = "-cargs"
              or else
            Argv = "-largs"
              or else
            Argv = "-margs"
      then
         case Argv (2) is
            when 'c' => Program_Args := Compiler;
            when 'b' => Program_Args := Binder;
            when 'l' => Program_Args := Linker;
            when 'm' => Program_Args := None;

            when others =>
               raise Program_Error;
         end case;

      --  A special test is needed for the -o switch within a -largs
      --  since that is another way to specify the name of the final
      --  executable.

      elsif Program_Args = Linker
        and then Argv = "-o"
      then
         Make_Failed ("switch -o not allowed within a -largs. " &
                      "Use -o directly.");

      --  Check to see if we are reading switches after a -cargs,
      --  -bargs or -largs switch. If yes save it.

      elsif Program_Args /= None then

         --  Check to see if we are reading -I switches in order
         --  to take into account in the src & lib search directories.

the flow-of-control fallthrus through the latter 2 'elsif's when the 'l' case 
is taken.

To reproduce: 

../../xgcc -c -I./ -I../rts -I. -I$srcdir/gcc/ada -B../../ -g -gnatpg -gnata 
-I- $srcdir/gcc/ada/make.adb

from the $objdir/gcc/ada/tools directory.

> Index: gimple-low.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/gimple-low.c,v
> retrieving revision 2.17
> diff -p -u -r2.17 gimple-low.c
> --- gimple-low.c	18 Jan 2005 11:36:14 -0000	2.17
> +++ gimple-low.c	21 Jan 2005 02:34:56 -0000
> @@ -278,11 +278,17 @@ block_may_fallthru (tree block)
>      case GOTO_EXPR:
>      case RETURN_EXPR:
>      case RESX_EXPR:
> -    case SWITCH_EXPR:
>        /* Easy cases.  If the last statement of the block implies
>  	 control transfer, then we can't fall through.  */
>        return false;
>
> +    case SWITCH_EXPR:
> +      /* If SWITCH_LABELS is set, this is lowered, and represents a
> +	 branch to a selected label and hence can not fall through.
> +	 Otherwise SWITCH_BODY is set, and the switch can fall
> +	 through.  */
> +      return SWITCH_LABELS (stmt) != NULL_TREE;
> +
>      case COND_EXPR:
>        if (block_may_fallthru (COND_EXPR_THEN (stmt)))
>  	return true;

Is it me or the code implements the reverse of what the comment says?

-- 
Eric Botcazou


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