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]

[Jakub Jelinek <jakub@redhat.com>] [PATCH] Fix libcpp do_linemarker (PR preprocessor/29612)


I would like to draw attention to this patch.  It is a simple patch
which fixes an annoying regression I discovered.  I wrote an
essentially equivalent patch before I had a valid copyright
assignment, so I've already looked into this problem, and I believe
this patch is correct.

The patch is to libcpp, which currently only has one maintainer, Per
Bothner, and he is not very active.  Other than Per, only GWPs can
approve patches to libcpp.

Mark, as the most active GWP, would you mind taking a look at this?

Thanks.

Ian

--- Begin Message ---
Hi!

As the attached testcases show, when handling # <linenum> <filename> <flags>
directives we were never clearing pfile->buffer->sysp, even when leaving
>From system header to non-system header (or main file).
AFAIK gcc -E outputs the 3 or 3 4 flags at the end for all # <linenum>
directives when in system headers, so we should trust those and when not
seeing these just reset pfile->buffer->sysp.

Ok for 4.1/4.2/4.3?

2006-11-08  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/29612
	* directives.c (do_linemarker): Set pfile->buffer->sysp always, not
	only when new_sysp is non-zero.

	* gcc.dg/cpp/pr29612-1.c: New test.
	* gcc.dg/cpp/pr29612-2.c: New test.

--- libcpp/directives.c.jj	2006-10-05 00:31:24.000000000 +0200
+++ libcpp/directives.c	2006-11-08 12:16:36.000000000 +0100
@@ -1,6 +1,7 @@
 /* CPP Library. (Directive handling.)
    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
    Contributed by Per Bothner, 1994-95.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -942,8 +943,8 @@ do_linemarker (cpp_reader *pfile)
 	  flag = read_flag (pfile, flag);
 	  if (flag == 4)
 	    new_sysp = 2;
-	  pfile->buffer->sysp = new_sysp;
 	}
+      pfile->buffer->sysp = new_sysp;
 
       check_eol (pfile);
     }
--- gcc/testsuite/gcc.dg/cpp/pr29612-1.c.jj	2006-11-08 12:52:28.000000000 +0100
+++ gcc/testsuite/gcc.dg/cpp/pr29612-1.c	2006-11-08 13:07:01.000000000 +0100
@@ -0,0 +1,15 @@
+/* PR preprocessor/29612 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+# 6 "pr29612-1.c"
+
+int foo (void) { return 'ab'; } /* { dg-warning "multi-character" } */
+
+# 1 "foo.h" 1 3
+
+int bar (void) { return 'ab'; } /* No warning in system header.  */
+
+# 14 "pr29612-1.c" 2
+
+int baz (void) { return 'ab'; } /* { dg-warning "multi-character" } */
--- gcc/testsuite/gcc.dg/cpp/pr29612-2.c.jj	2006-11-08 12:52:28.000000000 +0100
+++ gcc/testsuite/gcc.dg/cpp/pr29612-2.c	2006-11-08 13:01:59.000000000 +0100
@@ -0,0 +1,18 @@
+/* PR preprocessor/29612 */
+/* { dg-do preprocess } */
+/* { dg-options "-Wtraditional -fno-show-column" } */
+
+# 6 "pr29612-2.c"
+
+#if 1U /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
+#endif
+
+# 1 "foo.h" 1 3
+
+#if 1U
+#endif /* No warning in system header.  */
+
+# 16 "pr29612-2.c" 2
+
+#if 1U /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
+#endif

	Jakub



--- End Message ---

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