home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / gcc / bug / 2137 < prev    next >
Encoding:
Text File  |  1992-08-17  |  2.4 KB  |  77 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!monolith.mit.edu!cottons
  3. From: cottons@monolith.mit.edu (Cotton Seed)
  4. Subject: gcc 2.2.2 labeled element extension fails to parse in objective C code
  5. Message-ID: <9208170439.AA22387@_monolith.MIT.EDU_>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Mon, 17 Aug 1992 04:39:26 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 64
  12.  
  13. In article <9208040100.AA04267@slayer.MIT.EDU> mjhostet@slayer.mit.edu (Mathew J. Hostetter) writes:
  14. ] I am using gcc 2.2.2 on a 68040 NeXT running NeXTSTEP 3.0 pre-release  
  15. ] 1.
  16. ] gcc fails to parse an array of labels that uses the "label element"  
  17. ] extension when you are in objective-c mode and there is more than one  
  18. ] label in the array.  Otherwise it seems to work.  Here's how I tested  
  19. ] the enclosed function:
  20. ] slayer> gcc -c -x objective-c bad-label.c
  21. ] slayer> gcc -c -DLOSE bad-label.c 
  22. ] slayer> gcc -c -DLOSE -x objective-c bad-label.c
  23. ] bad-label.c: In function `foo':
  24. ] bad-label.c:5: parse error before `]'
  25. ] Here is bad-label.c:
  26. ] void
  27. ] foo ()
  28. ] {
  29. ] #ifdef LOSE
  30. ]   static const void *bar[] = { [5] &&label1, [10] &&label1 };
  31. ] #else
  32. ]   static const void *bar[] = { [5] &&label1 };  /* Only having one  
  33. ] elt works! */
  34. ] #endif
  35. ]  label1:
  36. ]   return;
  37. ] }
  38. ] -Mat
  39.  
  40. this bug was caused by an error in the objective C yacc grammer file
  41. [objc-parse.y] which failed to include the "initlist, init label
  42. element" construct [hence one label worked, while a list failed].
  43. this is easily fixed by the following diff, which inserts the missing
  44. construct into the grammer file....:
  45.  
  46. *** objc-parse.y        Sun Aug 16 23:25:15 1992
  47. --- objc-parse.y.orig   Wed Mar 25 15:54:47 1992
  48. ***************
  49. *** 878,885 ****
  50.         /* These are for labeled elements.  */
  51.         | '[' expr_no_commas ']' init
  52.                 { $$ = build_tree_list ($2, $4); }
  53. -       | initlist ',' '[' expr_no_commas ']' init
  54. -               { $$ = tree_cons ($4, $6, $1); }
  55.         | initlist ',' CASE expr_no_commas ':' init
  56.                 { $$ = tree_cons ($4, $6, $1); }
  57.         | identifier ':' init
  58. --- 878,883 ----
  59.  
  60. and with the patch, the bad-label.c example compiles correctly...:
  61.  
  62. monolith[NeXT]# ./gcc -B./ -c -x objective-c bad-label.c
  63. monolith[NeXT]# ./gcc -B./ -c -DLOSE -x objective-c bad-label.c
  64. monolith[NeXT]# 
  65.  
  66. --Cotton Seed [cottons@monolith.mit.edu]
  67. .
  68.  
  69.