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]

RFA: Get integrated CPP working again


This is Zack's patch to get integrated CPP working again.  It has
bootstrapped all frontends, and looks like it's about to finish
testing with no new regressions.

OK to commit?

Neil.

	Integrated CPP.  Zack Weinberg <zackw@Stanford.EDU>

	* c-lex.c (init_c_lex): Update cpp_start_read call.
	(cb_ident): Update for new callback prototype.
	(cb_def_pragma): Update for new cpp_get_token prototype.
	(c_lex): Similarly.  Use cpp_get_line.

	* c-parse.in (finish_parse): Update for new cpp_finish
	prototype.
	
	* cp/lex.c (finish_parse): Similarly.

Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.106
diff -u -p -r1.106 c-lex.c
--- c-lex.c	2000/10/08 21:20:43	1.106
+++ c-lex.c	2000/11/01 23:10:49
@@ -159,8 +159,7 @@ static void extend_token_buffer_to	PARAM
 static int read_line_number		PARAMS ((int *));
 static void process_directive		PARAMS ((void));
 #else
-static void cb_ident		PARAMS ((cpp_reader *, const unsigned char *,
-					 unsigned int));
+static void cb_ident		PARAMS ((cpp_reader *, const cpp_string *));
 static void cb_enter_file	PARAMS ((cpp_reader *));
 static void cb_leave_file	PARAMS ((cpp_reader *));
 static void cb_rename_file	PARAMS ((cpp_reader *));
@@ -221,7 +220,7 @@ init_c_lex (filename)
   /* Make sure parse_in.digraphs matches flag_digraphs.  */
   CPP_OPTION (&parse_in, digraphs) = flag_digraphs;
 
-  if (! cpp_start_read (&parse_in, 0 /* no printer */, filename))
+  if (! cpp_start_read (&parse_in, filename))
     abort ();
 
   if (filename == 0 || !strcmp (filename, "-"))
@@ -673,16 +672,15 @@ linenum:
    No need to deal with linemarkers under normal conditions.  */
 
 static void
-cb_ident (pfile, str, len)
+cb_ident (pfile, str)
      cpp_reader *pfile ATTRIBUTE_UNUSED;
-     const unsigned char *str;
-     unsigned int len;
+     const cpp_string *str;
 {
 #ifdef ASM_OUTPUT_IDENT
   if (! flag_no_ident)
     {
       /* Convert escapes in the string.  */
-      tree value = lex_string ((const char *)str, len, 0);
+      tree value = lex_string ((const char *)str->text, str->len, 0);
       ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (value));
     }
 #endif
@@ -785,11 +783,15 @@ cb_def_pragma (pfile)
      -Wunknown-pragmas has been given. */
   if (warn_unknown_pragmas > in_system_header)
     {
-      const unsigned char *space, *name;
-      const cpp_token *t = pfile->first_directive_token + 2;
+      const unsigned char *space, *name = 0;
+      cpp_token s;
 
-      space = t[0].val.node->name;
-      name  = t[1].type == CPP_NAME ? t[1].val.node->name : 0;
+      cpp_get_token (pfile, &s);
+      space = cpp_token_as_text (pfile, &s);
+      cpp_get_token (pfile, &s);
+      if (s.type == CPP_NAME)
+	name = cpp_token_as_text (pfile, &s);
+
       if (name)
 	warning ("ignoring #pragma %s %s", space, name);
       else
@@ -1417,64 +1419,56 @@ c_lex (value)
      tree *value;
 {
 #if USE_CPPLIB
-  const cpp_token *tok;
+  cpp_token tok;
   enum cpp_ttype type;
 
   retry:
   timevar_push (TV_CPP);
-  tok = cpp_get_token (&parse_in);
+  cpp_get_token (&parse_in, &tok);
   timevar_pop (TV_CPP);
 
   /* The C++ front end does horrible things with the current line
      number.  To ensure an accurate line number, we must reset it
-     every time we return a token.  If we reset it from tok->line
-     every time, we'll get line numbers inside macros referring to the
-     macro definition; this is nice, but we don't want to change the
-     behavior until integrated mode is the only option.  So we keep our
-     own idea of the line number, and reset it from tok->line at each
-     new line (which never happens inside a macro).  */
-  if (tok->flags & BOL)
-    lex_lineno = tok->line;
+     every time we return a token.  */
+  lex_lineno = cpp_get_line (&parse_in)->line;
 
   *value = NULL_TREE;
   lineno = lex_lineno;
-  type = tok->type;
+  type = tok.type;
   switch (type)
     {
     case CPP_OPEN_BRACE:  indent_level++;  break;
     case CPP_CLOSE_BRACE: indent_level--;  break;
 
-    /* Issue this error here, where we can get at tok->val.aux.  */
+    /* Issue this error here, where we can get at tok.val.aux.  */
     case CPP_OTHER:
-      if (ISGRAPH (tok->val.aux))
-	error ("stray '%c' in program", tok->val.aux);
+      if (ISGRAPH (tok.val.aux))
+	error ("stray '%c' in program", tok.val.aux);
       else
-	error ("stray '\\%#o' in program", tok->val.aux);
+	error ("stray '\\%#o' in program", tok.val.aux);
       goto retry;
       
-    case CPP_DEFINED:
-      type = CPP_NAME;
     case CPP_NAME:
-      *value = get_identifier ((const char *)tok->val.node->name);
+      *value = get_identifier ((const char *)tok.val.node->name);
       break;
 
     case CPP_INT:
     case CPP_FLOAT:
     case CPP_NUMBER:
-      *value = lex_number ((const char *)tok->val.str.text, tok->val.str.len);
+      *value = lex_number ((const char *)tok.val.str.text, tok.val.str.len);
       break;
 
     case CPP_CHAR:
     case CPP_WCHAR:
-      *value = lex_charconst ((const char *)tok->val.str.text,
-			      tok->val.str.len, tok->type == CPP_WCHAR);
+      *value = lex_charconst ((const char *)tok.val.str.text,
+			      tok.val.str.len, tok.type == CPP_WCHAR);
       break;
 
     case CPP_STRING:
     case CPP_WSTRING:
     case CPP_OSTRING:
-      *value = lex_string ((const char *)tok->val.str.text,
-			   tok->val.str.len, tok->type == CPP_WSTRING);
+      *value = lex_string ((const char *)tok.val.str.text,
+			   tok.val.str.len, tok.type == CPP_WSTRING);
       break;
 
       /* These tokens should not be visible outside cpplib.  */
Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-parse.in,v
retrieving revision 1.61
diff -u -p -r1.61 c-parse.in
--- c-parse.in	2000/11/01 07:32:22	1.61
+++ c-parse.in	2000/11/01 23:10:58
@@ -3060,7 +3060,7 @@ void
 finish_parse ()
 {
 #if USE_CPPLIB
-  cpp_finish (&parse_in, 0 /* no printer */);
+  cpp_finish (&parse_in);
   errorcount += parse_in.errors;
 #else
   fclose (finput);
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.218
diff -u -p -r1.218 lex.c
--- lex.c	2000/10/13 06:26:43	1.218
+++ lex.c	2000/11/01 23:11:08
@@ -775,7 +775,7 @@ void
 finish_parse ()
 {
 #if USE_CPPLIB
-  cpp_finish (&parse_in, 0 /* no printer */);
+  cpp_finish (&parse_in);
   errorcount += parse_in.errors;
 #else
   fclose (finput);

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