aboutsummaryrefslogtreecommitdiff
path: root/gcc/tradcpp.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2000-12-13 19:47:11 +0000
committerNeil Booth <neil@gcc.gnu.org>2000-12-13 19:47:11 +0000
commitc36ee1647b48c32193f007fd96f9759865fcba8a (patch)
treec232468f6550ec38fdf339bcbb7744f1b1d8f0b8 /gcc/tradcpp.c
parent04fd40b9d15b6374d3508259c86ed88d773bd988 (diff)
downloadgcc-c36ee1647b48c32193f007fd96f9759865fcba8a.zip
gcc-c36ee1647b48c32193f007fd96f9759865fcba8a.tar.gz
gcc-c36ee1647b48c32193f007fd96f9759865fcba8a.tar.bz2
tradcpp.c (special_symbol): Improve test for definedness, though it is still not perfect.
* tradcpp.c (special_symbol): Improve test for definedness, though it is still not perfect. (do_define): Don't define illegal macro names. From-SVN: r38230
Diffstat (limited to 'gcc/tradcpp.c')
-rw-r--r--gcc/tradcpp.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/gcc/tradcpp.c b/gcc/tradcpp.c
index c70845f..a0a55b8 100644
--- a/gcc/tradcpp.c
+++ b/gcc/tradcpp.c
@@ -2160,8 +2160,12 @@ special_symbol (hp, op)
if (!is_idstart (*ip->bufp))
goto oops;
- if (lookup (ip->bufp, -1, -1))
- buf = " 1 ";
+ {
+ HASHNODE *hp = lookup (ip->bufp, -1, -1);
+
+ if (hp && hp->type != T_UNUSED && hp->type != T_SPEC_DEFINED)
+ buf = " 1 ";
+ }
while (is_idchar (*ip->bufp))
++ip->bufp;
SKIP_WHITE_SPACE (ip->bufp);
@@ -2509,16 +2513,23 @@ do_define (buf, limit, op)
}
sym_length = bp - symname;
if (sym_length == 0)
- error ("invalid macro name");
+ {
+ error ("invalid macro name");
+ return;
+ }
else if (!is_idstart (*symname)) {
U_CHAR *msg; /* what pain... */
msg = (U_CHAR *) alloca (sym_length + 1);
memcpy (msg, symname, sym_length);
msg[sym_length] = 0;
error ("invalid macro name `%s'", msg);
+ return;
} else {
if (! strncmp ((const char *)symname, "defined", 7) && sym_length == 7)
- error ("defining `defined' as a macro");
+ {
+ error ("\"defined\" cannot be used as a macro name");
+ return;
+ }
}
/* lossage will occur if identifiers or control keywords are broken