This is the mail archive of the gcc-prs@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: preprocessor/4178: ICE with -imacros


The following reply was made to PR preprocessor/4178; it has been noted by GNATS.

From: Neil Booth <neil@daikokuya.demon.co.uk>
To: Gert-jan Los <gjlos@rz.uni-mannheim.de>
Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: preprocessor/4178: ICE with -imacros
Date: Thu, 30 Aug 2001 22:45:01 +0100

 Gert-jan Los wrote:-
 
 > 	GCC dies with an ICE even on trivial input if the -imacros switch is
 > 	used.
 > 	I suspect an oversight in the recent line mapping changes, because of
 > 	the negative line number in the error message. 
 
 Thanks for the bug report.
 
 No, it's just silly lossage in handling the internal linked lists of
 directives.
 
 This patch is not great; its only redeeming feature is that I think it
 fixes the bug.  Sometime in the next few days, when I'm a little less
 inebriated and have some spare time, I'll fix it properly 8-)
 
 I'm running a bootstrap now.  Let me know if this cures whatever code
 you have that caused you to notice the bug originally, and I'll commit
 it.
 
 I must find a way of getting -imacros and -include tests into dejagnu.
 They need to take absolute paths, which means I have no clue how to
 add tests for them...
 
 Neil.
 
 	* cppinit.c (cpp_start_read): Free the imacros list as we
 	traverse it.  Don't free the chains before returning.
 	(_cpp_push_next_buffer): Only try pushing buffers if we've
 	completed -imacros handling.
 
 Index: cppinit.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
 retrieving revision 1.176
 diff -u -p -r1.176 cppinit.c
 --- cppinit.c	2001/08/22 20:37:18	1.176
 +++ cppinit.c	2001/08/30 21:43:14
 @@ -958,18 +958,19 @@ cpp_start_read (pfile, fname)
  
        /* Scan -imacros files after command line defines, but before
  	 files given with -include.  */
 -      for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
 +      while ((p = CPP_OPTION (pfile, pending)->imacros_head) != NULL)
  	{
  	  if (push_include (pfile, p))
  	    {
  	      pfile->buffer->return_at_eof = true;
  	      cpp_scan_nooutput (pfile);
  	    }
 +	  CPP_OPTION (pfile, pending)->imacros_head = p->next;
 +	  free (p);
  	}
      }
  
    free_chain (CPP_OPTION (pfile, pending)->directive_head);
 -  free_chain (CPP_OPTION (pfile, pending)->imacros_head);
    _cpp_push_next_buffer (pfile);
  
    return 1;
 @@ -984,7 +985,12 @@ _cpp_push_next_buffer (pfile)
  {
    bool pushed = false;
  
 -  if (CPP_OPTION (pfile, pending))
 +  /* This is't pretty; we'd rather not be relying on this as a boolean
 +     for reverting the line map.  Further, we only free the chains in
 +     this conditional, so an early call to cpp_finish / cpp_destroy
 +     will leak that memory.  */
 +  if (CPP_OPTION (pfile, pending)
 +      && CPP_OPTION (pfile, pending)->imacros_head == NULL)
      {
        while (!pushed)
  	{


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