This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ridpointer problem [Re: block reordering problem]


On Sun, Sep 10, 2000 at 01:47:04PM -0700, Zack Weinberg wrote:
> For different reasons - the C++ front end has wondrous things in its
> ridpointers array, not just boring IDENTIFIER_NODEs.

Tasty.  Remind me not to ask.

> I do like this one better, though.  And it should deal with
> c-semantics.c's problem, too.

My thought exactly.

It turns out that we need a bit more help to pass a bootstrap:

One, if we enter "restrict" into the ridpointers table when that
keyword is disabled, then you'll get spurrious errors from __restrict.

Two, Objective C is being clever with enabling and disabling keywords
at runtime, which means that it needs extra help to get around the
fix for One.

The following has passed bootstrap and check on alpha-linux.


r~


        * c-parse.in: Revert last change.
        (init_reswords): Do not enter disabled keywords into the ridpointers
        table, modulo objc weirdness.
        (_yylex): Return the canonical spelling for a keyword.

Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-parse.in,v
retrieving revision 1.56
diff -c -p -d -r1.56 c-parse.in
*** c-parse.in	2000/09/10 07:07:20	1.56
--- c-parse.in	2000/09/10 20:57:39
*************** stmt:
*** 1901,1914 ****
  		{ stmt_count++;
  		  emit_line_note ($<filename>-1, $<lineno>0);
  		  c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
! 					 $2 && C_RID_CODE ($2) == RID_VOLATILE,
  					 input_filename, lineno); }
  	/* This is the case with input operands as well.  */
  	| ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
  		{ stmt_count++;
  		  emit_line_note ($<filename>-1, $<lineno>0);
  		  c_expand_asm_operands ($4, $6, $8, NULL_TREE,
! 					 $2 && C_RID_CODE ($2) == RID_VOLATILE,
  					 input_filename, lineno); }
  	/* This is the case with clobbered registers as well.  */
  	| ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
--- 1901,1914 ----
  		{ stmt_count++;
  		  emit_line_note ($<filename>-1, $<lineno>0);
  		  c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
! 					 $2 == ridpointers[(int)RID_VOLATILE],
  					 input_filename, lineno); }
  	/* This is the case with input operands as well.  */
  	| ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
  		{ stmt_count++;
  		  emit_line_note ($<filename>-1, $<lineno>0);
  		  c_expand_asm_operands ($4, $6, $8, NULL_TREE,
! 					 $2 == ridpointers[(int)RID_VOLATILE],
  					 input_filename, lineno); }
  	/* This is the case with clobbered registers as well.  */
  	| ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
*************** stmt:
*** 1916,1922 ****
  		{ stmt_count++;
  		  emit_line_note ($<filename>-1, $<lineno>0);
  		  c_expand_asm_operands ($4, $6, $8, $10,
! 					 $2 && C_RID_CODE ($2) == RID_VOLATILE,
  					 input_filename, lineno); }
  	| GOTO identifier ';'
  		{ tree decl;
--- 1916,1922 ----
  		{ stmt_count++;
  		  emit_line_note ($<filename>-1, $<lineno>0);
  		  c_expand_asm_operands ($4, $6, $8, $10,
! 					 $2 == ridpointers[(int)RID_VOLATILE],
  					 input_filename, lineno); }
  	| GOTO identifier ';'
  		{ tree decl;
*************** init_reswords ()
*** 3061,3068 ****
  {
    unsigned int i;
    tree id;
!   int mask = (D_YES
! 	      | (doing_objc_thang ? 0 : D_OBJC)
  	      | (flag_isoc99 ? 0 : D_C89)
  	      | (flag_traditional ? D_TRAD : 0)
  	      | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0));
--- 3061,3067 ----
  {
    unsigned int i;
    tree id;
!   int mask = ((doing_objc_thang ? 0 : D_OBJC)
  	      | (flag_isoc99 ? 0 : D_C89)
  	      | (flag_traditional ? D_TRAD : 0)
  	      | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0));
*************** init_reswords ()
*** 3073,3082 ****
    ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
    for (i = 0; i < N_reswords; i++)
      {
        id = get_identifier (reswords[i].word);
        C_RID_CODE (id) = reswords[i].rid;
        ridpointers [(int) reswords[i].rid] = id;
!       if (! (reswords[i].disable & mask))
  	C_IS_RESERVED_WORD (id) = 1;
      }
  }
--- 3072,3090 ----
    ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
    for (i = 0; i < N_reswords; i++)
      {
+       /* If a keyword is disabled, do not enter it into the table
+ 	 and so create a canonical spelling that isn't a keyword.  */
+       if (reswords[i].disable & mask)
+ 	continue;
+ 
        id = get_identifier (reswords[i].word);
        C_RID_CODE (id) = reswords[i].rid;
        ridpointers [(int) reswords[i].rid] = id;
! 
!       /* Objective C does tricky things with enabling and disabling 
! 	 keywords.  So these we must not elide in the test above, but
! 	 wait and not mark them reserved now.  */
!       if (! (reswords[i].disable & D_YES))
  	C_IS_RESERVED_WORD (id) = 1;
      }
  }
*************** _yylex ()
*** 3219,3225 ****
  
      case CPP_NAME:
        if (C_IS_RESERVED_WORD (yylval.ttype))
! 	return rid_to_yy[C_RID_CODE (yylval.ttype)];
  
        if (IDENTIFIER_POINTER (yylval.ttype)[0] == '@')
  	{
--- 3227,3238 ----
  
      case CPP_NAME:
        if (C_IS_RESERVED_WORD (yylval.ttype))
! 	{
! 	  enum rid rid_code = C_RID_CODE (yylval.ttype);
! 	  /* Return the canonical spelling for this keyword.  */
! 	  yylval.ttype = ridpointers[(int) rid_code];
! 	  return rid_to_yy[(int) rid_code];
! 	}
  
        if (IDENTIFIER_POINTER (yylval.ttype)[0] == '@')
  	{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]