This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.3 patch] Permission to backport regression fix ?!?
- From: neroden at twcny dot rr dot com (Nathanael Nerode)
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 9 Dec 2003 18:25:57 -0500
- Subject: [3.3 patch] Permission to backport regression fix ?!?
I've asked a couple of times about this. It's in mainline, and fixes
a bug in cpp -traditional which is present in 3.3 and is a regression from
3.2 (although it's not reported to Bugzilla).
May I please have permission to backport the patch to 3.3 and commit?
The affected code was the same in 3.3 branch and 3.4 mainline, so there
should be no problem.
* cpptrad.c (_cpp_scan_out_logical_line): Improve test for
whether directive begins at the beginning of a line.
(testsuite)
* gcc.dg/cpp/trad/xwin1.c: New test case.
http://gcc.gnu.org/ml/gcc-patches/2003-11/msg01543.html
Here's the patch again:
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpptrad.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- gcc/gcc/cpptrad.c 2003/11/01 22:56:54 1.38
+++ gcc/gcc/cpptrad.c 2003/11/19 18:48:24 1.39
@@ -350,6 +350,7 @@
unsigned int c, paren_depth = 0, quote;
enum ls lex_state = ls_none;
bool header_ok;
+ const uchar *start_of_input_line;
fmacro.buff = NULL;
@@ -359,6 +360,9 @@
RLIMIT (pfile->context) = pfile->buffer->rlimit;
pfile->out.cur = pfile->out.base;
pfile->out.first_line = pfile->line;
+ /* start_of_input_line is needed to make sure that directives really,
+ really start at the first character of the line. */
+ start_of_input_line = pfile->buffer->cur;
new_context:
context = pfile->context;
cur = CUR (context);
@@ -581,7 +585,7 @@
break;
case '#':
- if (out - 1 == pfile->out.base
+ if (cur - 1 == start_of_input_line
/* A '#' from a macro doesn't start a directive. */
&& !pfile->context->prev
&& !pfile->state.in_directive)
=============================
And here's the test case again:
/* XWindows (as of 4.3) does some pretty strange things with cpp.
This tests one of them; the leading comments are supposed to be
eaten by the preprocessor; but the 'directives' after them are
supposed to be retained as text, not processed, so that imake's cpp
can be run on the output!
{ dg-do preprocess }
*/
/**/#if 0
passed
/**/#endif
/* { dg-final { scan-file xwin1.i "(^|\n)#if 0" } } */
--
Nathanael Nerode <neroden at gcc.gnu.org>
http://home.twcny.rr.com/nerode/neroden/fdl.html