This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] macro redefinition with different token count
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dj at redhat dot com
- Date: Thu, 29 May 2003 22:47:15 -0500 (CDT)
- Subject: Re: [patch] macro redefinition with different token count
- Organization: Networks and Infrastructure Lab (IL02/2240), Motorola Labs
> * cppmacro.c (warn_of_redefinition): Handle cases where the two
> definitions have different numbers of tokens.
Thanks DJ, I can confirm that this fixes the test case in
preprocessor/11022 (thus consider adding an annotation and closing
that PR when you commit). I revised the posted test case into dejagnu
form (consider committing it along with your patch since this problem
wasn't covered by the existing tests) and covered the related oddity.
(I'd say that your fix is obviously correct, but I'm only adding some bits.)
* gcc.dg/cpp/redef3.c: New file.
Index: gcc/testsuite/gcc.dg/cpp/redef3.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/cpp/redef3.c
diff -N gcc/testsuite/gcc.dg/cpp/redef3.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/cpp/redef3.c 30 May 2003 03:44:20 -0000
***************
*** 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 }
+ */