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]

(C++) cpplib fix


We were failing to tell cpplib what file and line the regurgitated input
came from.

1999-07-26  Jason Merrill  <jason@yorick.cygnus.com>

	* input.c (feed_input): Add file, line parms.
	* lex.c (begin_definition_of_inclass_inline, feed_defarg): Adjust.
	(real_yylex): Check linemode before input_redirected().

Index: input.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/input.c,v
retrieving revision 1.11
diff -c -p -r1.11 input.c
*** input.c	1999/07/20 19:53:31	1.11
--- input.c	1999/07/26 22:23:03
*************** extern unsigned char *yy_cur, *yy_lim;
*** 69,75 ****
  extern int yy_get_token ();
  #endif
  
! extern void feed_input PROTO((char *, int));
  extern void put_input PROTO((int));
  extern void put_back PROTO((int));
  extern int getch PROTO((void));
--- 69,75 ----
  extern int yy_get_token ();
  #endif
  
! extern void feed_input PROTO((char *, int, char *, int));
  extern void put_input PROTO((int));
  extern void put_back PROTO((int));
  extern int getch PROTO((void));
*************** free_input (inp)
*** 110,118 ****
  
  inline
  void
! feed_input (str, len)
       char *str;
       int len;
  {
    struct input_source *inp = allocate_input ();
  
--- 110,120 ----
  
  inline
  void
! feed_input (str, len, file, line)
       char *str;
       int len;
+      char *file;
+      int line;
  {
    struct input_source *inp = allocate_input ();
  
*************** feed_input (str, len)
*** 126,131 ****
--- 128,136 ----
      my_friendly_abort (990710);
    cpp_push_buffer (&parse_in, str, len);
    CPP_BUFFER (&parse_in)->manual_pop = 1;
+   CPP_BUFFER (&parse_in)->nominal_fname
+     = CPP_BUFFER (&parse_in)->fname = file;
+   CPP_BUFFER (&parse_in)->lineno = line;
  #else
    inp->str = str;
    inp->length = len;
*************** feed_input (str, len)
*** 134,139 ****
--- 139,146 ----
    putback.buffer = NULL;
    putback.buffer_size = 0;
    putback.index = -1;
+   lineno = line;
+   input_filename = file;
  #endif
    inp->next = input;
    inp->filename = input_filename;
Index: lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.123
diff -c -p -r1.123 lex.c
*** lex.c	1999/07/24 00:45:50	1.123
--- lex.c	1999/07/26 22:23:03
*************** begin_definition_of_inclass_inline (pi)
*** 1266,1274 ****
    if (context)
      push_cp_function_context (context);
  
!   feed_input (pi->buf, pi->len);
!   lineno = pi->lineno;
!   input_filename = pi->filename;
    yychar = PRE_PARSED_FUNCTION_DECL;
    yylval.ttype = build_tree_list ((tree) pi, pi->fndecl);
    /* Pass back a handle to the rest of the inline functions, so that they
--- 1266,1272 ----
    if (context)
      push_cp_function_context (context);
  
!   feed_input (pi->buf, pi->len, pi->filename, pi->lineno);
    yychar = PRE_PARSED_FUNCTION_DECL;
    yylval.ttype = build_tree_list ((tree) pi, pi->fndecl);
    /* Pass back a handle to the rest of the inline functions, so that they
*************** feed_defarg (f, p)
*** 1878,1889 ****
       tree f, p;
  {
    tree d = TREE_PURPOSE (p);
!   feed_input (DEFARG_POINTER (d), DEFARG_LENGTH (d));
    if (TREE_CODE (f) == FUNCTION_DECL)
      {
!       lineno = DECL_SOURCE_LINE (f);
!       input_filename = DECL_SOURCE_FILE (f);
      }
    yychar = DEFARG_MARKER;
    yylval.ttype = p;
  }
--- 1876,1895 ----
       tree f, p;
  {
    tree d = TREE_PURPOSE (p);
!   char *file;
!   int line;
    if (TREE_CODE (f) == FUNCTION_DECL)
      {
!       line = DECL_SOURCE_LINE (f);
!       file = DECL_SOURCE_FILE (f);
      }
+   else
+     {
+       line = lineno;
+       file = input_filename;
+     }
+ 
+   feed_input (DEFARG_POINTER (d), DEFARG_LENGTH (d), file, line);
    yychar = DEFARG_MARKER;
    yylval.ttype = p;
  }
*************** real_yylex ()
*** 3557,3566 ****
      case EOF:
        end_of_file = 1;
        token_buffer[0] = 0;
!       if (input_redirected ())
! 	value = END_OF_SAVED_INPUT;
!       else if (linemode)
  	value = END_OF_LINE;
        else
  	value = ENDFILE;
        break;
--- 3563,3572 ----
      case EOF:
        end_of_file = 1;
        token_buffer[0] = 0;
!       if (linemode)
  	value = END_OF_LINE;
+       else if (input_redirected ())
+ 	value = END_OF_SAVED_INPUT;
        else
  	value = ENDFILE;
        break;


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