PATCH: Fix PR 2033

Mark Mitchell mark@codesourcery.com
Thu Apr 19 12:54:00 GMT 2001


This patch fixes a problem with the design of our command-line
processing stuff.  We didn't give front-ends any way of saying that a
command-line option should not be processed by language-independent
code, resulting in g77's `-ffixed-line-length-none' option being
interpreted as `-ffixed' with `line-length-none' as the name of a
register.

Bootstrapped, tested on i686-pc-linux-gnu, installed on the branch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-04-19  Mark Mitchell  <mark@codesourcery.com>

	* toplev.h (struct lang_hooks): Allow decode_option to indicate
	that language-independent processing should not be done.
	* toplev.c (main): Adjust accordingly.

Thu Apr 19 12:49:24 2001  Mark Mitchell  <mark@codesourcery.com>

	* top.c (ffe_decode_option): Do not permit language-independent
	processing for -ffixed-line-length.

Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.420.2.11
diff -c -p -r1.420.2.11 toplev.c
*** toplev.c	2001/04/16 18:25:40	1.420.2.11
--- toplev.c	2001/04/19 19:39:52
*************** main (argc, argv)
*** 4740,4755 ****
    /* Perform normal command line switch decoding.  */
    for (i = 1; i < argc;)
      {
!       unsigned int lang_processed;
!       unsigned int indep_processed;
  
        /* Give the language a chance to decode the option for itself.  */
        lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
  
!       /* Now see if the option also has a language independent meaning.
! 	 Some options are both language specific and language independent,
! 	 eg --help.  */
!       indep_processed = independent_decode_option (argc - i, argv + i);
  
        if (lang_processed || indep_processed)
  	i += MAX (lang_processed, indep_processed);
--- 4740,4761 ----
    /* Perform normal command line switch decoding.  */
    for (i = 1; i < argc;)
      {
!       int lang_processed;
!       int indep_processed;
  
        /* Give the language a chance to decode the option for itself.  */
        lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
  
!       if (lang_processed >= 0)
! 	/* Now see if the option also has a language independent meaning.
! 	   Some options are both language specific and language independent,
! 	   eg --help.  */
! 	indep_processed = independent_decode_option (argc - i, argv + i);
!       else
! 	{
! 	  lang_processed = -lang_processed;
! 	  indep_processed = 0;
! 	}
  
        if (lang_processed || indep_processed)
  	i += MAX (lang_processed, indep_processed);
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.52.2.2
diff -c -p -r1.52.2.2 toplev.h
*** toplev.h	2001/02/23 21:18:14	1.52.2.2
--- toplev.h	2001/04/19 19:39:52
*************** struct lang_hooks
*** 155,161 ****
       single option (typically starting with -f or -W or +).  It should
       return the number of command-line arguments it uses if it handles
       the option, or 0 and not complain if it does not recognise the
!      option.  This hook cannot be NULL.  */
    int (*decode_option) PARAMS ((int, char **));
  
    /* Called when all command line options have been processed.  */
--- 155,166 ----
       single option (typically starting with -f or -W or +).  It should
       return the number of command-line arguments it uses if it handles
       the option, or 0 and not complain if it does not recognise the
!      option.  If this function returns a negative number, then its
!      absolute value is the number of command-line arguments used, but,
!      in addition, no language-independent option processing should be
!      done for this option.
! 
!      This hook cannot be NULL.  */
    int (*decode_option) PARAMS ((int, char **));
  
    /* Called when all command line options have been processed.  */
Index: f/top.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/top.c,v
retrieving revision 1.23
diff -c -p -r1.23 top.c
*** top.c	2000/08/19 13:20:07	1.23
--- top.c	2001/04/19 19:39:52
***************
*** 1,5 ****
  /* top.c -- Implementation File (module.c template V1.0)
!    Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
     Contributed by James Craig Burley.
  
  This file is part of GNU Fortran.
--- 1,5 ----
  /* top.c -- Implementation File (module.c template V1.0)
!    Copyright (C) 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
     Contributed by James Craig Burley.
  
  This file is part of GNU Fortran.
*************** ffe_decode_option (argc, argv)
*** 464,472 ****
  	  char *len = &opt[2] + strlen ("fixed-line-length-");
  
  	  if (strcmp (len, "none") == 0)
! 	    ffe_set_fixed_line_length (0);
  	  else if (ffe_is_digit_string_ (len))
! 	    ffe_set_fixed_line_length (atol (len));
  	  else
  	    return 0;
  	}
--- 464,478 ----
  	  char *len = &opt[2] + strlen ("fixed-line-length-");
  
  	  if (strcmp (len, "none") == 0)
! 	    {
! 	      ffe_set_fixed_line_length (0);
! 	      return -1;
! 	    }
  	  else if (ffe_is_digit_string_ (len))
! 	    {
! 	      ffe_set_fixed_line_length (atol (len));
! 	      return -1;
! 	    }
  	  else
  	    return 0;
  	}



More information about the Gcc-patches mailing list