PATCH: Parse '@class' properly (was: Re: libobjc With --enable-c-cpplib)
Manfred Hollstein
mhollstein@cygnus.com
Sun Dec 5 03:35:00 GMT 1999
Didn't get any feedback on the patch below so far. If someone of you
finds some time to comment, I'd appreciate.
Cheers.
l8er
manfred
On Sat, 23 October 1999, 18:34:15, mhollstein@cygnus.com wrote:
> Hi all,
>
> On Tue, 5 October 1999, 17:22:14, brolley@cygnus.com wrote:
>
> > Hi,
> >
> > I'm having a problem building linking.m in libobjc with the cpplib
> > enabled xgcc. It looks like the '@' character in '@class' is being
> > returned as an identifier. I'm not sure when this started happening,
> > since I haven't built with --enable-c-cpplib for a while. Does this
> > have anything to do with the discussion we had about what to do with
> > random illegal characters?
> >
>
> The problem Dave is describing started happening with this change:
>
> Wed Aug 4 12:53:44 1999 Jason Merrill <jason@yorick.cygnus.com>
>
> * c-lex.c (lang_init): Generalize.
> (nextchar): Remove. Replace uses with UNGETC.
> (skip_white_space): Handle linemode here. Optimize for cpplib.
> (skip_white_space_on_line): Remove.
> (extend_token_buffer_to): New fn.
> (extend_token_buffer): Use it.
> (read_line_number, check_newline): Just deal with tokens.
> (token_getch, token_put_back): New fns.
> (yylex): Use them. More cpplib optimizations. Simplify.
>
> Tokens like @class, @"string" aren't scanned as one token, instead the
> token_buffer just contains the '@'. When 'token_getch' is called to read
> the following stuff, it's just returning a null character:
>
> >From c-lex.c, line 1200:
>
> /* Get the next character, staying within the current token if possible.
> If we're lexing a token, we don't want to look beyond the end of the
> token cpplib has prepared for us; otherwise, we end up reading in the
> next token, which screws up feed_input. So just return a null
> character. */
>
> which prevents recognition of those particular Obj-C tokens.
>
> This patch fixes it:
>
> 1999-10-23 Manfred Hollstein <mhollstein@cygnus.com>
>
> * c-lex.c (yylex): Undo change to call 'token_getch' when last
> token was a '@' and we're doing Obj-C.
>
> diff -rup -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ -x version.el egcs-19991023.orig/gcc/c-lex.c egcs-19991023/gcc/c-lex.c
> --- egcs-19991023.orig/gcc/c-lex.c Fri Oct 8 18:30:33 1999
> +++ egcs-19991023/gcc/c-lex.c Sat Oct 23 17:58:26 1999
> @@ -1319,7 +1319,7 @@ yylex ()
> else
> {
> /* '@' may start a constant string object. */
> - register int c = token_getch ();
> + register int c = GETC ();
> if (c == '"')
> {
> objc_flag = 1;
>
> OK to install?
>
> Cheers.
>
> l8er
> manfred
>
> > make[1]: Entering directory
> > `/notnfs/brolley/comp/egcs/cpplib/H-i686-pc-linux-gnu/O-i686-pc-linux-gnu/i686-pc-linux-gnu/libobjc'
> >
> > /notnfs/brolley/comp/egcs/cpplib/H-i686-pc-linux-gnu/O-i686-pc-linux-gnu/gcc/xgcc
> > -B/notnfs/brolley/comp/egcs/cpplib/H-i686-pc-linux-gnu/O-i686-pc-linux-gnu/gcc/
> > -B/notnfs/brolley/comp/egcs/cpplib/H-i686-pc-linux-gnu/i686-pc-linux-gnu/bin/
> > -fgnu-runtime -c -o linking.o -I.
> > -I/home/brolley/comp/egcs/egcs/libobjc -g -O2 -DIN_GCC
> > -I/home/brolley/comp/egcs/egcs/libobjc/objc
> > -I/home/brolley/comp/egcs/egcs/libobjc/../gcc
> > -I/home/brolley/comp/egcs/egcs/libobjc/../gcc/config -I../../gcc
> > -I/home/brolley/comp/egcs/egcs/libobjc/../include
> > /home/brolley/comp/egcs/egcs/libobjc/linking.m
> > In file included from
> > /home/brolley/comp/egcs/egcs/libobjc/objc/Object.h:30,
> > from
> > /home/brolley/comp/egcs/egcs/libobjc/linking.m:28:
> > /home/brolley/comp/egcs/egcs/libobjc/objc/objc.h:141: invalid
> > identifier `@'
> > /home/brolley/comp/egcs/egcs/libobjc/objc/objc.h:141: parse error
> > before `class'
> > /home/brolley/comp/egcs/egcs/libobjc/objc/objc.h:141: warning: data
> > definition has no type or storage class
> > In file included from
> > /home/brolley/comp/egcs/egcs/libobjc/linking.m:28:
> > /home/brolley/comp/egcs/egcs/libobjc/objc/Object.h:37: invalid
> > identifier `@'
> > /home/brolley/comp/egcs/egcs/libobjc/objc/Object.h:37: parse error
> > before `interface'
> > /home/brolley/comp/egcs/egcs/libobjc/objc/Object.h:38: syntax error
> > before `{'
> > /home/brolley/comp/egcs/egcs/libobjc/objc/Object.h:43: method
> > definition not in class context
> > make[1]: *** [linking.o] Error 1
> > make[1]: Leaving directory
> > `/notnfs/brolley/comp/egcs/cpplib/H-i686-pc-linux-gnu/O-i686-pc-linux-gnu/i686-pc-linux-gnu/libobjc'
> >
> > make: *** [all-target-libobjc] Error 2
> > make: Leaving directory
> > `/notnfs/brolley/comp/egcs/cpplib/H-i686-pc-linux-gnu/O-i686-pc-linux-gnu'
> >
> >
> >
> > Dave
> >
>
More information about the Gcc-bugs
mailing list