This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ preprocessor bug or not ?
- To: John Levon <moz at compsoc dot man dot ac dot uk>
- Subject: Re: C++ preprocessor bug or not ?
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Date: Tue, 6 Feb 2001 19:18:26 +0000
- Cc: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- References: <Pine.LNX.4.21.0102061144440.15285-100000@mrworry.compsoc.man.ac.uk>
Hi John,
As Dave and Philipp pointed out, CPP is correct. However, the diagnostic
is awful.
This patch address that; it outputs
/tmp/test.c:1:14: operator "defined" requires an identifier
/tmp/test.c:1:14: ("xor" is an alternative token for "^" in C++)
Neil.
* cppexp.c (parse_defined): Improve diagnostics for invalid
syntax.
Index: cppexp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppexp.c,v
retrieving revision 1.85
diff -u -p -r1.85 cppexp.c
--- cppexp.c 2001/01/28 01:50:05 1.85
+++ cppexp.c 2001/02/06 19:17:04
@@ -344,7 +344,20 @@ parse_defined (pfile)
}
}
else
- cpp_error (pfile, "\"defined\" without an identifier");
+ {
+ cpp_error (pfile, "operator \"defined\" requires an identifier");
+ if (token.flags & NAMED_OP)
+ {
+ cpp_token op;
+
+ op.flags = 0;
+ op.type = token.type;
+ cpp_error (pfile,
+ "(\"%s\" is an alternative token for \"%s\" in C++)",
+ cpp_token_as_text (pfile, &token),
+ cpp_token_as_text (pfile, &op));
+ }
+ }
if (!node)
op.op = CPP_ERROR;