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]

SPEC parsing bugs


Hi Guys,

  I would like permission to apply the following patch.  It fixes a
  couple of small bugs in the spec string parser:

  1. If %* is used in a substitution pattern, but it has not been
     initialised by a corresponding '*' in the match pattern, gcc will 
     seg fault.  This can be reproduced by a spec pattern like this:

       %{foo:f%*}

  2. If an unknown character is used a spec opterator, gcc will abort
     without producing any error message.  This can be reproduced by a
     spec string like this:

       %foo

  OK to apply ?

Cheers
	Nick


2000-03-06  Nick Clifton  <nickc@cygnus.com>

	* gcc.c (do_spec_1): Catch the case where %* is used in a
	substitution pattern, but it has not been initialised.
	Issue a meaningful error message if an unrecognised operator
	is encountered in a spec string.

Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcc.c,v
retrieving revision 1.132
diff -p -r1.132 gcc.c
*** gcc.c	2000/02/26 06:23:30	1.132
--- gcc.c	2000/03/06 21:09:20
*************** do_spec_1 (spec, inswitch, soft_matched_
*** 4406,4413 ****
  	    break;
  
  	  case '*':
! 	    do_spec_1 (soft_matched_part, 1, NULL_PTR);
! 	    do_spec_1 (" ", 0, NULL_PTR);
  	    break;
  
  	    /* Process a string found as the value of a spec given by name.
--- 4406,4422 ----
  	    break;
  
  	  case '*':
! 	    if (soft_part_matched)
! 	      {
! 		do_spec_1 (soft_matched_part, 1, NULL_PTR);
! 		do_spec_1 (" ", 0, NULL_PTR);
! 	      }
! 	    else
! 	      /* Catch the case where a spec string contains something like
! 		 '%{foo:%*}'.  ie there is no * in the pattern on the left
! 		 hand side of the :.  */
! 	      error ("Spec failure: '%%*' has not been initialised by pattern match");
! 
  	    break;
  
  	    /* Process a string found as the value of a spec given by name.
*************** do_spec_1 (spec, inswitch, soft_matched_
*** 4558,4564 ****
  	    break;
  
  	  default:
! 	    abort ();
  	  }
  	break;
  
--- 4567,4574 ----
  	    break;
  
  	  default:
! 	    error ("Spec failure: Unrecognised spec option '%c'", c);
! 	    break;
  	  }
  	break;
  

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