This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Update gengtype-lex.l to allow for C90 function typedefs
- From: Kelley Cook <kcook34 at ford dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: aj at suse dot de
- Date: Fri, 03 Oct 2003 14:47:03 -0400
- Subject: [PATCH] Update gengtype-lex.l to allow for C90 function typedefs
- Hop-count: 1
- Reply-to: Kelley Cook <kelleycook at wideopenwest dot com>
In this message http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00883.html,
Andreas Jaeger noted that converting three java files to C90
inexplicably caused a bootstrap failure.
It turns out that it was because gengtype-lex.l in two cases was
expecting the PARAMS macro to be present. I simply duplicated those two
cases changing PARAMS to "(" and the magic numbers 7 to 2 to reflect the
strlen differences between " PARAMS" and " (".
As a correctness check, rerunning the new ./gengtype outputed all of its
files identically to pre-patch. Moreover, after converting those three
Java files to C90 -- which I can commit as obvious if this patch
approved -- another run of ./gengtype still outputted the exact same files.
Bootstrapped on i686-pc-cygwin. OK to install?
2003-10-03 Kelley Cook <kelleycook@wideopenwest.com>
* gengtype-lex.l: Recognize typedef of functions without PARAMS macro.
--- gengtype-lex.l.orig 2003-10-03 11:35:12.863117500 -0400
+++ gengtype-lex.l 2003-10-03 12:26:10.740620000 -0400
@@ -132,6 +132,23 @@
do_typedef (xmemdup (namestart, namelen, namelen+1), t, &lexer_line);
update_lineno (yytext, yyleng);
}
+
+[^[:alnum:]_]typedef{WS}{ID}{WS}{ID}{WS}"(" {
+ char *namestart;
+ size_t namelen;
+ struct type *t;
+
+ for (namestart = yytext + yyleng - 2; ISSPACE (*namestart); namestart--)
+ ;
+ for (namelen = 1; !ISSPACE (namestart[-namelen]); namelen++)
+ ;
+ namestart -= namelen - 1;
+
+ t = create_scalar_type ("function type", sizeof ("function type")-1);
+ do_typedef (xmemdup (namestart, namelen, namelen+1), t, &lexer_line);
+ update_lineno (yytext, yyleng);
+}
+
[^[:alnum:]_]typedef{WS}{ID}{WS}?"("{WS}?"*"{WS}?{ID}{WS}?")"{WS}?PARAMS {
char *namestart;
size_t namelen;
@@ -148,6 +165,22 @@
update_lineno (yytext, yyleng);
}
+[^[:alnum:]_]typedef{WS}{ID}{WS}?"("{WS}?"*"{WS}?{ID}{WS}?")"{WS}?"(" {
+ char *namestart;
+ size_t namelen;
+ struct type *t;
+
+ for (namestart = yytext + yyleng - 2; !ISIDNUM (*namestart); namestart--)
+ ;
+ for (namelen = 1; ISIDNUM (namestart[-namelen]); namelen++)
+ ;
+ namestart -= namelen - 1;
+
+ t = create_scalar_type ("function type", sizeof ("function type")-1);
+ do_typedef (xmemdup (namestart, namelen, namelen+1), t, &lexer_line);
+ update_lineno (yytext, yyleng);
+}
+
[^[:alnum:]_](typedef{WS})?(struct|union){WS}{ID}{WS}/"GTY" {
char *tagstart;
size_t taglen;