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: Gcc 3.3 regressions (fwd)


Neil has just approved this in private, so I've checked it in, branch
and mainline.  Here's the exact patch that went into mainline, for the
record.

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

	* cpplib.c (do_pragma): Reintroduce cb_line_change call in the
	code path that calls a handler.

Index: gcc/cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.351
diff -u -p -r1.351 cpplib.c
--- gcc/cpplib.c 16 Sep 2003 00:13:28 -0000 1.351
+++ gcc/cpplib.c 24 Sep 2003 23:51:14 -0000
@@ -1120,7 +1120,7 @@ static void
 do_pragma (cpp_reader *pfile)
 {
   const struct pragma_entry *p = NULL;
-  const cpp_token *token;
+  const cpp_token *token, *pragma_token = pfile->cur_token;
   unsigned int count = 1;
 
   pfile->state.prevent_expansion++;
@@ -1141,7 +1141,17 @@ do_pragma (cpp_reader *pfile)
     }
 
   if (p)
-    p->u.handler (pfile);
+    {
+      /* Since the handler below doesn't get the line number, that it
+	 might need for diagnostics, make sure it has the right
+	 numbers in place.  */
+      if (pfile->cb.line_change)
+	(*pfile->cb.line_change) (pfile, pragma_token, false);
+      (*p->u.handler) (pfile);
+      if (pfile->cb.line_change)
+	(*pfile->cb.line_change) (pfile, pfile->cur_token, false);
+      
+    }
   else if (pfile->cb.def_pragma)
     {
       _cpp_backup_tokens (pfile, count);
Index: gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* gcc.dg/cpp/Wunknown-pragmas-1.c: New test.

Index: gcc/testsuite/gcc.dg/cpp/Wunknown-pragmas-1.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/cpp/Wunknown-pragmas-1.c
diff -N gcc/testsuite/gcc.dg/cpp/Wunknown-pragmas-1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/cpp/Wunknown-pragmas-1.c 24 Sep 2003 23:51:29 -0000
@@ -0,0 +1,29 @@
+/* Copyright 2003 Free Software Foundation, Inc.  */
+
+/* { dg-do compile } */
+/* { dg-options "-Wunknown-pragmas" } */
+
+/* Make sure we get warnings in the expected lines.  */
+
+#pragma unknown1 /* { dg-warning "unknown1" "unknown1" } */
+
+#define COMMA ,
+#define FOO(x) x
+#define BAR(x) _Pragma("unknown_before") x
+#define BAZ(x) x _Pragma("unknown_after")
+
+int _Pragma("unknown2") bar1; /* { dg-warning "unknown2" "unknown2" } */
+
+FOO(int _Pragma("unknown3") bar2); /* { dg-warning "unknown3" "unknown3" } */
+
+int BAR(bar3); /* { dg-warning "unknown_before" "unknown_before 1" } */
+
+BAR(int bar4); /* { dg-warning "unknown_before" "unknown_before 2" } */
+
+int BAZ(bar5); /* { dg-warning "unknown_after" "unknown_after 1" } */
+
+int BAZ(bar6;) /* { dg-warning "unknown_after" "unknown_after 2" } */
+
+FOO(int bar7; _Pragma("unknown4")) /* { dg-warning "unknown4" "unknown4" } */
+
+#pragma unknown5 /* { dg-warning "unknown5" "unknown5" } */
-- 
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]