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]
Other format: [Raw text]

Re: [3.3 regression] fix incorrect line break before functional macro name


On Sep 14, 2003, Neil Booth <neil@daikokuya.co.uk> wrote:

> Alexandre Oliva wrote:-
>> Bootstrapped and regression tested on athlon-pc-linux-gnu.  Ok to
>> install in the 3.3 branch?  Ok for mainline as well?

>> Index: gcc/ChangeLog
>> from  Alexandre Oliva  <aoliva@redhat.com>
>> 
>> * c-ppoutput.c (cb_line_change): Revert 2003-08-04's change.
>> * c-lex.c (cb_line_change): Skip line changing whenever
>> c-ppoutput.c would.

> OK for both.

Thanks.  I adjusted the ChangeLog for 3.3 to reference cppmain.c
instead of c-ppoutput.c (thanks, Jakub!), and ported the patch to
mainline (K&R -> ISO C prototypes and testsuite syntax).  Here's what
I'm checking in to mainline.

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* c-ppoutput.c (cb_line_change): Revert 2003-08-04's change.
	* c-lex.c (cb_line_change): Skip line changing whenever
	c-ppoutput.c would.

Index: gcc/c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.212
diff -u -p -r1.212 c-lex.c
--- gcc/c-lex.c 12 Sep 2003 05:03:21 -0000 1.212
+++ gcc/c-lex.c 14 Sep 2003 13:51:31 -0000
@@ -197,8 +197,11 @@ cb_ident (cpp_reader *pfile ATTRIBUTE_UN
    lexed token on the line.  Used for diagnostic line numbers.  */
 static void
 cb_line_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const cpp_token *token,
-		int parsing_args ATTRIBUTE_UNUSED)
+		int parsing_args)
 {
+  if (token->type == CPP_EOF || parsing_args)
+    return;
+
   src_lineno = SOURCE_LINE (map, token->line);
 }
 
Index: gcc/c-ppoutput.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-ppoutput.c,v
retrieving revision 1.8
diff -u -p -r1.8 c-ppoutput.c
--- gcc/c-ppoutput.c 4 Aug 2003 16:49:38 -0000 1.8
+++ gcc/c-ppoutput.c 14 Sep 2003 13:51:31 -0000
@@ -261,9 +261,9 @@ print_line (const struct line_map *map, 
    of the line, and at end of file will be CPP_EOF.  */
 static void
 cb_line_change (cpp_reader *pfile, const cpp_token *token,
-		int parsing_args ATTRIBUTE_UNUSED)
+		int parsing_args)
 {
-  if (token->type == CPP_EOF)
+  if (token->type == CPP_EOF || parsing_args)
     return;
 
   maybe_print_line (print.map, token->line);
Index: gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* gcc.dg/cpp/separate-1.c: Adjust line of error.  Test for correct
	non-expansion of functional macro name without arguments at EOL.
	* gcc.dg/cpp/spacing1.c: Revert 2003-08-04's change.  Likewise.

Index: gcc/testsuite/gcc.dg/cpp/separate-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/cpp/separate-1.c,v
retrieving revision 1.1
diff -u -p -r1.1 separate-1.c
--- gcc/testsuite/gcc.dg/cpp/separate-1.c 4 Aug 2003 16:49:28 -0000 1.1
+++ gcc/testsuite/gcc.dg/cpp/separate-1.c 14 Sep 2003 13:51:40 -0000
@@ -8,5 +8,8 @@
 
 #define FOO()
 
-int FOO(
-	), bar; /* { dg-error "(parse|syntax) error" "error on this line" } */
+int FOO( /* { dg-error "(parse|syntax) error" "error on this line" } */
+	), bar;
+
+int baz FOO /* { dg-error "(parse|syntax) error" "error on this line" } */
+; /* { dg-warning "no type or storage class" "warning on this line" } */
Index: gcc/testsuite/gcc.dg/cpp/spacing1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/cpp/spacing1.c,v
retrieving revision 1.5
diff -u -p -r1.5 spacing1.c
--- gcc/testsuite/gcc.dg/cpp/spacing1.c 6 Aug 2003 21:33:32 -0000 1.5
+++ gcc/testsuite/gcc.dg/cpp/spacing1.c 14 Sep 2003 13:51:40 -0000
@@ -14,14 +14,10 @@
    invocation is not defined: we might consider them to be in the same
    line as the initial token of the invocation, or as the final token
    of the invocation, or even anything in between.  We choose to make
-   it the final token, but we might as well collapse the invocation
-   and the rest of the line into the initial line, such that `g
-   ... bam baz' below were all in a single line in the preprocessor
-   output.  We used to do this at some point, but it disagreed with
-   the way we numbered lines with the integrated preprocessor, so we
-   had to pick one of them to change.
+   it the initial token, such that everything that is in a logical
+   line ends up in a single line after preprocessing.
 
-   Alexandre Oliva, Aug 5, 2003.  */
+   Alexandre Oliva, Sept 13, 2003.  */
 
 #define str(x) #x
 #define f(x) x
@@ -41,18 +37,18 @@
 B Q B Q A Q A:
 f
 bar
-g
+A
+bad
+g "1 2" bam baz
 
-
-
- "1 2"
- bam baz
 */
 
 glue (EMPTY 4, 4) EMPTY;
 A(Q) C(Q) D()Q D():
 f
 bar
+A
+bad
 f (g) str
 (
 1
@@ -64,6 +60,6 @@ f (g) str
    { dg-final { scan-file spacing1.i "B Q B Q A Q A:" } }
    { dg-final { scan-file-not spacing1.i "f\[^\n\]*bar" } }
    { dg-final { scan-file spacing1.i "(^|\n)bar" } }
-   { dg-final { scan-file spacing1.i "(^|\n)g($|\n)" } }
-   { dg-final { scan-file spacing1.i "(^|\n) \"1 2\"" } }
-   { dg-final { scan-file spacing1.i "(^|\n) bam baz" } } */
+   { dg-final { scan-file spacing1.i "(^|\n)A($|\n)" } }
+   { dg-final { scan-file spacing1.i "(^|\n)bad($|\n)" } }
+   { dg-final { scan-file spacing1.i "g \"1 2\" bam baz" } } */
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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