This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] macro redefinition with different token count


warn_of_redefinition goes to great lengths to compare tokens for
equality, but doesn't handle the case where there are different
numbers of tokens - it silently allows the redefinition.

2003-05-29  DJ Delorie  <dj@redhat.com>

	* cppmacro.c (warn_of_redefinition): Handle cases where the two
	definitions have different numbers of tokens.

Index: cppmacro.c
===================================================================
RCS file: /usr/dj/gnu/gcc/repository/gcc/gcc/cppmacro.c,v
retrieving revision 1.133
diff -p -2 -r1.133 cppmacro.c
*** cppmacro.c	24 Apr 2003 20:03:57 -0000	1.133
--- cppmacro.c	29 May 2003 23:34:21 -0000
*************** warn_of_redefinition (pfile, node, macro
*** 1276,1283 ****
      return _cpp_expansions_different_trad (macro1, macro2);
  
!   if (macro1->count == macro2->count)
!     for (i = 0; i < macro1->count; i++)
!       if (!_cpp_equiv_tokens (&macro1->exp.tokens[i], &macro2->exp.tokens[i]))
! 	return true;
  
    return false;
--- 1276,1285 ----
      return _cpp_expansions_different_trad (macro1, macro2);
  
!   if (macro1->count != macro2->count)
!     return true;
! 
!   for (i = 0; i < macro1->count; i++)
!     if (!_cpp_equiv_tokens (&macro1->exp.tokens[i], &macro2->exp.tokens[i]))
!       return true;
  
    return false;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]