diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-13 19:47:11 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-13 19:47:11 +0000 |
commit | 370f8928be64012444d56f6d5392d77fe148096f (patch) | |
tree | c232468f6550ec38fdf339bcbb7744f1b1d8f0b8 /gcc/tradcpp.c | |
parent | 86c039f44fd9f315d591540e9c692f4f9919b587 (diff) | |
download | gcc-370f8928be64012444d56f6d5392d77fe148096f.tar.gz |
* tradcpp.c (special_symbol): Improve test for definedness,
though it is still not perfect.
(do_define): Don't define illegal macro names.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38230 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tradcpp.c')
-rw-r--r-- | gcc/tradcpp.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/gcc/tradcpp.c b/gcc/tradcpp.c index c70845fa5df..a0a55b8167d 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 |