public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* cppmacro.c: Small fix
@ 2002-07-26  9:43 Neil Booth
  0 siblings, 0 replies; only message in thread
From: Neil Booth @ 2002-07-26  9:43 UTC (permalink / raw)
  To: gcc-patches

I noticed this when looking at something else.  If we define what was an
assertion as a macro, we do redefinition checks.  These assume they're
passed a macro, and start dereferencing things.  The only reason we
don't crash is that the pointer is valid, but it points to assertion
internals rather than macro internals.

Neil.

	* cppmacro.c (_cpp_create_definition): Don't attempt redefinition
	warnings on assertions.

Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.118
diff -u -p -r1.118 cppmacro.c
--- cppmacro.c	23 Jul 2002 22:57:44 -0000	1.118
+++ cppmacro.c	26 Jul 2002 16:25:14 -0000
@@ -1547,7 +1547,7 @@ _cpp_create_definition (pfile, node)
   if (!ok)
     return ok;
 
-  if (node->type != NT_VOID)
+  if (node->type == NT_MACRO)
     {
       if (CPP_OPTION (pfile, warn_unused_macros))
 	_cpp_warn_if_unused_macro (pfile, node, NULL);
@@ -1562,8 +1562,10 @@ _cpp_create_definition (pfile, node)
 				 node->value.macro->line, 0,
 			 "this is the location of the previous definition");
 	}
-      _cpp_free_definition (node);
     }
+
+  if (node->type != NT_VOID)
+    _cpp_free_definition (node);
 
   /* Enter definition in hash table.  */
   node->type = NT_MACRO;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-07-26 16:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-26  9:43 cppmacro.c: Small fix Neil Booth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).