This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: fix -Wtrigraphs double warnings
- To: gcc-patches at gcc dot gnu dot org
- Subject: cpplib: fix -Wtrigraphs double warnings
- From: Neil Booth <neilb at earthling dot net>
- Date: Wed, 22 Nov 2000 20:15:42 +0000
- Cc: Zack Weinberg <zackw at Stanford dot EDU>
As pointed out by Zack a couple of weeks back. I suddenly realised
there's a trivial fix today. With the new code:-
bash-2.04$ ./cpp0 -Wtrigraphs
abcdef??<
# 1 ""
<stdin>:1:7: warning: trigraph ??< ignored
abcdef??<
bash-2.04$
Neil.
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.119
diff -u -p -r1.119 cpplex.c
--- cpplex.c 2000/11/14 18:32:06 1.119
+++ cpplex.c 2000/11/22 20:04:11
@@ -159,9 +159,13 @@ trigraph_ok (pfile, from_char)
"trigraph ??%c converted to %c",
(int) from_char,
(int) _cpp_trigraph_map[from_char]);
- else
- cpp_warning_with_line (pfile, buffer->lineno, CPP_BUF_COL (buffer) - 2,
- "trigraph ??%c ignored", (int) from_char);
+ else if (buffer->cur != buffer->last_Wtrigraphs)
+ {
+ buffer->last_Wtrigraphs = buffer->cur;
+ cpp_warning_with_line (pfile, buffer->lineno,
+ CPP_BUF_COL (buffer) - 2,
+ "trigraph ??%c ignored", (int) from_char);
+ }
}
return accept;
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.137
diff -u -p -r1.137 cpplib.h
--- cpplib.h 2000/11/20 18:27:31 1.137
+++ cpplib.h 2000/11/22 20:04:15
@@ -282,6 +282,10 @@ struct cpp_buffer
/* Line number at line_base (above). */
unsigned int lineno;
+ /* Because of the way the lexer works, -Wtrigraphs can sometimes
+ warn twice for the same trigraph. This helps prevent that. */
+ const unsigned char *last_Wtrigraphs;
+
/* True if we have already warned about C++ comments in this file.
The warning happens only for C89 extended mode with -pedantic on,
or for -Wtraditional, and only once per file (otherwise it would