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

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

* gcc.dg/cpp/redef3.c: New file.

From-SVN: r67307
This commit is contained in:
DJ Delorie 2003-06-01 14:55:15 -04:00
parent 8e2b6930e1
commit a7f36da379
4 changed files with 36 additions and 4 deletions

View file

@ -1,3 +1,8 @@
2003-05-29 DJ Delorie <dj@redhat.com>
* cppmacro.c (warn_of_redefinition): Handle cases where the two
definitions have different numbers of tokens.
2003-06-01 Andreas Jaeger <aj@suse.de>
* gen-protos.c (main): Readd unused attribute for argc.

View file

@ -1275,10 +1275,12 @@ warn_of_redefinition (pfile, node, macro2)
if (CPP_OPTION (pfile, traditional))
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;
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;
}

View file

@ -1,3 +1,7 @@
2003-06-01 Loren James Rittle <ljrittle@acm.org>
* gcc.dg/cpp/redef3.c: New file.
2003-06-01 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/i386-loop-3.c: New test.

View file

@ -0,0 +1,21 @@
/* Test for redefining macros with mismatch token count (and the oddity). */
/* { dg-do preprocess } */
/* { dg-options "-DC -DD=1 -DE" } */
#define A
#define A 1
#define B 2 3
#define B 2
#define C 1
#define D 1 2
#define E
/* { dg-warning "redefined" "redef A" { target *-*-* } 7 }
{ dg-warning "redefined" "redef B" { target *-*-* } 9 }
{ dg-warning "redefined" "redef D" { target *-*-* } 11 }
{ dg-warning "redefined" "redef E" { target *-*-* } 12 }
{ dg-warning "previous" "prev def A" { target *-*-* } 6 }
{ dg-warning "previous" "prev def B" { target *-*-* } 8 }
{ dg-warning "previous" "prev def D/E" { target *-*-* } 0 }
*/