This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] cpplib sig11 fix
- To: Zack Weinberg <zack at wolery dot cumb dot org>, gcc-patches at gcc dot gnu dot org
- Subject: [PATCH] cpplib sig11 fix
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Tue, 6 Jun 2000 16:19:17 +0200
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
Hi!
If cpp is fed with
#ifdef 0
somestuff
#endif
then it dies with sig11, which is IMHO not very good even for lame input.
Patch below fixes this.
BTW: This was handled as a warning previously, is it intentionally an error
now or not? (not that I want to type such lame stuff)
2000-06-06 Jakub Jelinek <jakub@redhat.com>
* cpplib.c (do_ifdef, do_ifndef): Don't segfault if parse_ifdef
returned NULL.
--- gcc/cpplib.c.jj Fri Jun 2 01:09:18 2000
+++ gcc/cpplib.c Tue Jun 6 15:18:39 2000
@@ -1126,10 +1126,13 @@ do_ifdef (pfile)
{
int def = 0;
const cpp_hashnode *node = parse_ifdef (pfile, dtable[T_IFDEF].name);
- if (node->type == T_POISON)
- cpp_error (pfile, "attempt to use poisoned `%s'", node->name);
- else
- def = (node->type != T_VOID);
+ if (node)
+ {
+ if (node->type == T_POISON)
+ cpp_error (pfile, "attempt to use poisoned `%s'", node->name);
+ else
+ def = (node->type != T_VOID);
+ }
push_conditional (pfile, !def, T_IFDEF, 0);
return 0;
}
@@ -1147,11 +1150,13 @@ do_ifndef (pfile)
start_of_file = pfile->only_seen_white == 2;
cmacro = parse_ifdef (pfile, dtable[T_IFNDEF].name);
- if (cmacro->type == T_POISON)
- cpp_error (pfile, "attempt to use poisoned `%s'", cmacro->name);
- else
- def = (cmacro->type != T_VOID);
-
+ if (cmacro)
+ {
+ if (cmacro->type == T_POISON)
+ cpp_error (pfile, "attempt to use poisoned `%s'", cmacro->name);
+ else
+ def = (cmacro->type != T_VOID);
+ }
push_conditional (pfile, def, T_IFNDEF,
start_of_file ? cmacro : 0);
return 0;
Jakub