🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Cotton Seed Mon, 17 Aug 1992 04:39
gcc 2.2.2 labeled element extension fails to parse in objective C code
#952
Author: Cotton Seed
Date: Mon, 17 Aug 1992 04:39
63 lines
2485 bytes
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]
.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads