home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / gnu / gcc / bug / 2655 < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.1 KB  |  69 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: Enums fail in labeled element array initalization extension
  5. Message-ID: <9211072114.AA13186@monolith.MIT.EDU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Sat, 7 Nov 1992 11:14:21 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 56
  12.  
  13. The following bug exists in both gcc v2.3.1, as well as in snapshot 921106, on  
  14. a 68040 NeXT running NeXTSTEP v3.0.  Both versions of gcc [v2.3.1 and ss921106]  
  15. were built with gcc v2.3.1 with optimization level 2, but in no other way  
  16. deviated from the standard installation process:
  17.  
  18. monolith[NeXT]% cat test.c
  19. enum { NUM = 5 };
  20.  
  21. int bad_array[] = { [NUM] 9 };
  22. int good_array[] = { [5] 9 };
  23. int another_good_array[] = { [4 + 1] 9 };
  24.  
  25. monolith[NeXT]% gcc -c test.c
  26. test.c:3: non-constant array index in initializer
  27.  
  28. [NOTE: this bug had been previously reported by mjhostet@athena.mit.edu in 
  29.  
  30. [message <9211022214.AA05706@slayer.MIT.EDU>.
  31.  
  32. the following diff [made from the ss921106 source.  this code has not changed  
  33. since 2.3.1 release, so the diff would be the same minus date modification  
  34. times].
  35.  
  36. monolith[NeXT]# diff -c c-typeck.c c-typeck.c.orig 
  37.  
  38. *** c-typeck.c  Sat Nov  7 15:56:55 1992
  39. --- c-typeck.c.orig     Sat Nov  7 15:56:36 1992
  40. ***************
  41. *** 4970,4976 ****
  42.               int win = 0;
  43.               tree index = TREE_PURPOSE (tail);
  44.   
  45.  
  46. !             if (index && (TREE_CODE (index) == NON_LVALUE_EXPR || TREE_CODE  
  47. (index) == NOP_EXPR))
  48.                 index = TREE_OPERAND (index, 0);
  49.   
  50.  
  51.               /* Begin a range.  */
  52. --- 4970,4976 ----
  53.               int win = 0;
  54.               tree index = TREE_PURPOSE (tail);
  55.   
  56.  
  57. !             if (index && TREE_CODE (index) == NON_LVALUE_EXPR)
  58.                 index = TREE_OPERAND (index, 0);
  59.   
  60.  
  61.               /* Begin a range.  */
  62.  
  63. in the case of ENUMS, the tree code is NON_EXPR, so this code merely exposes  
  64. the constant residing in the operand portion of the index tree node.
  65.  
  66. NOTE: this does not deal with problems in the range array initialization,  
  67. including its failure to handle enums in the ranges.
  68.  
  69.