Problem with debugging quoted backslash-newline in macro

Paul Eggert eggert@twinsun.com
Sat Dec 5 23:09:00 GMT 1998


   From: Ian Lance Taylor <ian@airs.com>
   Date: 3 Dec 1998 22:24:48 -0500

   Between egcs 1.0.3 and egcs 1.1 a bug was introduced into the C
   preprocessor which affects the generation of debugging information
   when using a macro with a backslash-newline in a string.

Yes, sorry, I introduced that bug when fixing some other
backslash-newline problems in cccp.c.  There were several bugs in the
neighborhood.  I just installed the following big patch in the GCC2
sources, which should address all the cpp bugs that I know about.

This patch adds one new option -Wwhite-space, implied by -Wall; it
detects probable errors like backslash-space-newline in strings or
macros.

Here are some major remaining cpp issues.  The first is more pressing,
I think.

* Support for draft C9x (especially the \u escapes), especially in the
  light of the new MULTIBYTE_CHARS stuff.

* Making cpplib and cccp use the same code, rather than two code bases.

1998-12-05  Paul Eggert  <eggert@twinsun.com>

	Add new option -Wwhite-space, implied by -Wall.
	If DEPENDENCIES_OUTPUT is `FILE TARGET', have TARGET depend on source.
	Simplify VMS fwrite workaround.
	Bug fixes (notably with backslash-newlines in strings).
	Allow multiple-char constants like 'abcde' that are longer than long.
	Other minor porting issues.
	
	* cpp.texi: Document -Wwhite-space, implied by -Wall.

	* cccp.c (fwrite): New VMS macro.
	(VMS_fwrite): New VMS function.
	(strerror): Declare only if NEED_DECLARATION_STRERROR.
	(warn_white_space): New var.
	(do_warning): Remove.
	(directive_table): Use do_error to print warnings.
	(eprint_string): Remove.  All callers now use fwrite instead.
	(check_white_space): New function.
	(fatal): Now extern; it's needed by cexp.y on some platforms.
	(main): Add new option --White-space, implied by -Wall.
	If DEPENDENCIES_OUTPUT has the form `FILE TARGET',
	have TARGET depend on the source file as well as the files
	that it includes.
	(newline_fix, name_newline_fix): Assume that *BP == '\\',
	but don't assume that BP[1] == '\n'.  This shortens the callers' code.
	All callers changed.
	(rescan): Warn about white space at end of line in string.
	Fix bug with counting newlines in strings as the result of
	macro-expanding.
	(expand_to_temp_buffer): Do not stomp on the output buffer length;
	we need the length field for expand_size (see below).
	All callers changed.
	(handle_directive): No need to check bp < limit if *bp == '\n'.
	Allocate a larger directive buffer; expand newline
	to backslash-'n' in string literals.
	(timestamp): Don't assume that localtime succeeds.
	(finclude): Add call to check_white_space in included file.
	(collect_expansion): No need to check for p < limit at backslash.
	(do_line): Allow nulls in file name.
	(do_error): Also do warnings.
	(do_pragma): Handle escapes in strings correctly.
	(skip_quoted_string): Don't say ``Unterminated string or
	character'' if it's known to be a character.
	Warn about white space at end of line in string.
	(struct argdata): New member expand_size, giving allocated size
	of expansion.
	Rename member stringified_length to stringified_length_bound.
	All uses changed.
	(macroexpand): Record expand_size separately from expand_length.
	Generate nothing for backslash-newline in a string.
	Escape newlines in strings.
	(macarg): Have macarg1 count newlines.  Escape newlines in strings.
	(macarg1): Skip backslash-newline in strings.
	(change_newlines): Now takes struct argdata * (not U_CHAR * and int)
	returns void, not int.  Modify the arg in-place.
	(change_newlines, make_definition): In strings, replace
	backslash-newline with nothing, and non-backslashed newline
	with backslash-'n'.

	* cexp.y (fatal): New decl (exported by cccp.c).
	(yylex): Allow multiple-char constants like 'abcde' that are longer
	than long; draft C9x requires this.  Don't treat (char)-1 like EOF.
	(parse_escape): Return -2 if backslash-newline is seen.
	Parse backslash-newline in numeric escapes.
	Parse \x using unsigned, not signed, for proper overflow detection.







More information about the Gcc-bugs mailing list