home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: sparky!uunet!cis.ohio-state.edu!monolith.mit.edu!cottons
- From: cottons@monolith.mit.edu (Cotton Seed)
- Subject: gcc 2.2.2 labeled element extension fails to parse in objective C code
- Message-ID: <9208170439.AA22387@_monolith.MIT.EDU_>
- Sender: gnulists@ai.mit.edu
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Mon, 17 Aug 1992 04:39:26 GMT
- Approved: bug-gcc@prep.ai.mit.edu
- Lines: 64
-
- In article <9208040100.AA04267@slayer.MIT.EDU> mjhostet@slayer.mit.edu (Mathew J. Hostetter) writes:
- ] I am using gcc 2.2.2 on a 68040 NeXT running NeXTSTEP 3.0 pre-release
- ] 1.
- ]
- ] gcc fails to parse an array of labels that uses the "label element"
- ] extension when you are in objective-c mode and there is more than one
- ] label in the array. Otherwise it seems to work. Here's how I tested
- ] the enclosed function:
- ]
- ] slayer> gcc -c -x objective-c bad-label.c
- ] slayer> gcc -c -DLOSE bad-label.c
- ]
- ] slayer> gcc -c -DLOSE -x objective-c bad-label.c
- ] bad-label.c: In function `foo':
- ] bad-label.c:5: parse error before `]'
- ]
- ]
- ] Here is bad-label.c:
- ]
- ] void
- ] foo ()
- ] {
- ] #ifdef LOSE
- ] static const void *bar[] = { [5] &&label1, [10] &&label1 };
- ] #else
- ] static const void *bar[] = { [5] &&label1 }; /* Only having one
- ] elt works! */
- ] #endif
- ]
- ] label1:
- ] return;
- ] }
- ]
- ] -Mat
-
- this bug was caused by an error in the objective C yacc grammer file
- [objc-parse.y] which failed to include the "initlist, init label
- element" construct [hence one label worked, while a list failed].
- this is easily fixed by the following diff, which inserts the missing
- construct into the grammer file....:
-
- *** objc-parse.y Sun Aug 16 23:25:15 1992
- --- objc-parse.y.orig Wed Mar 25 15:54:47 1992
- ***************
- *** 878,885 ****
- /* These are for labeled elements. */
- | '[' expr_no_commas ']' init
- { $$ = build_tree_list ($2, $4); }
- - | initlist ',' '[' expr_no_commas ']' init
- - { $$ = tree_cons ($4, $6, $1); }
- | initlist ',' CASE expr_no_commas ':' init
- { $$ = tree_cons ($4, $6, $1); }
- | identifier ':' init
- --- 878,883 ----
-
- and with the patch, the bad-label.c example compiles correctly...:
-
- monolith[NeXT]# ./gcc -B./ -c -x objective-c bad-label.c
- monolith[NeXT]# ./gcc -B./ -c -DLOSE -x objective-c bad-label.c
- monolith[NeXT]#
-
- --Cotton Seed [cottons@monolith.mit.edu]
- .
-
-