This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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]

[patch/testsuite] compiler.cc, compiler.c: work with old hp acc


This is a one-line patch to make the test suite run with old hp aC++
compilers.  I recently switched to an older hpux and I got hurt by this.
This happens with hp aC++ A.03.13 but is fixed in hp aCC A.03.45.  

lib/compiler.cc says:

  set compiler_info "unknown"

  #if foo
  ...
  #endif

  #if defined (_HP_aCC)
  blah blah blah
  #endif

The hp aC++ preprocessor emits:

  set compiler_info "unknown"blah blah blah

That's right, it eats the newline!  This gives lib/gdb.exp indigestion
because it's eval'ing this output as tcl commands.

After some experimentation and cursing, it looks like their compiler
does aggressive string concatenation.  If the last token in the line is
a string, then the preprocessor eats the newline in order to merge with
the first token on the next line, in case that token is a string.

The patch is simple: add another token at the end of the line, like a
semicolon.  That makes the preprocessor respect the newlines.

Tested on:

  native i686-pc-linux-gnu, gcc 2.95.3 3.3.3 3.4.0, dwarf-2 stabs+
  native hppa2.0w-hp-hpux11.00, hp ansi c A.11.01.25171.GP,
    hp aC++ A.03.13

I don't have access to the newer hp aC++ (A.03.45) but since this
works with A.03.13 it should work with A.03.45.

I am committing this now,

Michael C

2004-06-30  Michael Chastain   <mec.gnu@mindspring.com>

	* lib/compiler.cc: Work around string preprocessing problem
	with old hp c++ compiler.
	* lib/compiler.c: Likewise.

Index: lib/compiler.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/compiler.cc,v
retrieving revision 1.7
diff -c -3 -p -r1.7 compiler.cc
*** lib/compiler.cc	14 Jun 2004 15:29:30 -0000	1.7
--- lib/compiler.cc	30 Jun 2004 06:10:01 -0000
***************
*** 22,28 ****
  /* This file is exactly like compiler.c.  I could just use compiler.c if
     I could be sure that every C++ compiler accepted extensions of ".c".  */
  
! set compiler_info "unknown"
  
  #if defined (__GNUC__)
  #if defined (__GNUC_PATCHLEVEL__)
--- 22,35 ----
  /* This file is exactly like compiler.c.  I could just use compiler.c if
     I could be sure that every C++ compiler accepted extensions of ".c".  */
  
! /* Note the semicolon at the end of this line.  Older versions of
!    hp c++ have a bug in string preprocessing: if the last token on a
!    line is a string, then the preprocessor concatenates the next line
!    onto the current line and eats the newline!  That messes up TCL of
!    course.  That happens with HP aC++ A.03.13, but it no longer happens
!    with HP aC++ A.03.45. */
! 
! set compiler_info "unknown" ;
  
  #if defined (__GNUC__)
  #if defined (__GNUC_PATCHLEVEL__)
Index: lib/compiler.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/compiler.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 compiler.c
*** lib/compiler.c	14 Jun 2004 15:29:30 -0000	1.5
--- lib/compiler.c	30 Jun 2004 06:10:01 -0000
***************
*** 34,40 ****
  
     TODO: purge signed_keyword_not_used.  */
  
! set compiler_info "unknown"
  
  #if defined (__GNUC__)
  #if defined (__GNUC_PATCHLEVEL__)
--- 34,47 ----
  
     TODO: purge signed_keyword_not_used.  */
  
! /* Note the semicolon at the end of this line.  Older versions of
!    hp c++ have a bug in string preprocessing: if the last token on a
!    line is a string, then the preprocessor concatenates the next line
!    onto the current line and eats the newline!  That messes up TCL of
!    course.  That happens with HP aC++ A.03.13, but it no longer happens
!    with HP aC++ A.03.45. */
! 
! set compiler_info "unknown" ;
  
  #if defined (__GNUC__)
  #if defined (__GNUC_PATCHLEVEL__)


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