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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH for java/15543 that works with --enable-mapped-location


The attached patch lets us bootstrap gcc/java with
--enable-mapped-location.  It replaces Ranjits's earlier fix
for PR java/15543, which had the problem that it explicitly
sets input_filename and input_line - which are no longer lvalues.
Since we don't really track line-numbers in jv-scan - and it
will likely get removed anyway - I decided to use a different
variable: main_input_filename, and remove all use of input_location
from jv-scan.

Tested with no regressions, and checked into mainline.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/
2005-02-11  Per Bothner  <per@bothner.com>

	PR java/15543
	* parse-scan.y (input_location): Remove variable.
	(main_input_filename): New - replaces input_filename, which isn't
	settable if USE_MAPPED_LOCATION.
	* lex.c (java_init_lex): Wrap some more places in #ifndef JC1-LITE,
	so we don't reference input_location or wfl_operator in that case.
	* jv-scan.c (expand_location): Remove - no longer used.
	(main): Set main_input_filename rather than input_filename.

Index: jv-scan.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jv-scan.c,v
retrieving revision 1.45
diff -u -p -r1.45 jv-scan.c
--- jv-scan.c	2 Feb 2005 18:41:24 -0000	1.45
+++ jv-scan.c	11 Feb 2005 17:37:18 -0000
@@ -131,29 +131,6 @@ version (void)
   exit (0);
 }
 
-#ifdef USE_MAPPED_LOCATION
-/* FIXME - this is the same as the function in tree.c, which is awkward.
-   Probably the cleanest solution is to move the function to line-map.c.
-   This is difficult as long as we still support --disable-mapped-location,
-   since whether expanded_location has a column fields depends on
-   USE_MAPPED_LOCATION. */
-
-expanded_location
-expand_location (source_location loc)
-{
-  expanded_location xloc;
-  if (loc == 0) { xloc.file = NULL; xloc.line = 0;  xloc.column = 0; }
-  else
-    {
-      const struct line_map *map = linemap_lookup (&line_table, loc);
-      xloc.file = map->to_file;
-      xloc.line = SOURCE_LINE (map, loc);
-      xloc.column = SOURCE_COLUMN (map, loc);
-    };
-  return xloc;
-}
-#endif
-
 /* jc1-lite main entry point */
 int
 main (int argc, char **argv)
@@ -237,8 +214,7 @@ main (int argc, char **argv)
 	    if (encoding == NULL || *encoding == '\0')
 	      encoding = DEFAULT_ENCODING;
 
-            input_filename = filename;
-            input_line = 0;
+            main_input_filename = filename;
 	    java_init_lex (finput, encoding);
 	    ctxp->filename = filename;
 	    yyparse ();
Index: lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.c,v
retrieving revision 1.118
diff -u -p -r1.118 lex.c
--- lex.c	16 Oct 2004 18:27:32 -0000	1.118
+++ lex.c	11 Feb 2005 17:37:18 -0000
@@ -108,11 +108,13 @@ java_init_lex (FILE *finput, const char 
 
   if (!wfl_operator)
     {
+#ifndef JC1_LITE
 #ifdef USE_MAPPED_LOCATION
       wfl_operator = build_expr_wfl (NULL_TREE, input_location);
 #else
       wfl_operator = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
 #endif
+#endif
     }
   if (!label_id)
     label_id = get_identifier ("$L");
@@ -134,7 +136,9 @@ java_init_lex (FILE *finput, const char 
   ctxp->package = NULL_TREE;
 #endif
 
+#ifndef JC1_LITE
   ctxp->save_location = input_location;
+#endif
   ctxp->java_error_flag = 0;
   ctxp->lexer = java_new_lexer (finput, encoding);
 }
@@ -1471,7 +1475,6 @@ do_java_lex (YYSTYPE *java_lval)
 #ifndef JC1_LITE
       java_lval->operator.token = OCB_TK;
       java_lval->operator.location = BUILD_LOCATION();
-#endif
 #ifdef USE_MAPPED_LOCATION
       if (ctxp->ccb_indent == 1)
 	ctxp->first_ccb_indent1 = input_location;
@@ -1479,14 +1482,14 @@ do_java_lex (YYSTYPE *java_lval)
       if (ctxp->ccb_indent == 1)
 	ctxp->first_ccb_indent1 = input_line;
 #endif
+#endif
       ctxp->ccb_indent++;
       return OCB_TK;
     case '}':
+      ctxp->ccb_indent--;
 #ifndef JC1_LITE
       java_lval->operator.token = CCB_TK;
       java_lval->operator.location = BUILD_LOCATION();
-#endif
-      ctxp->ccb_indent--;
 #ifdef USE_MAPPED_LOCATION
       if (ctxp->ccb_indent == 1)
         ctxp->last_ccb_indent1 = input_location;
@@ -1494,6 +1497,7 @@ do_java_lex (YYSTYPE *java_lval)
       if (ctxp->ccb_indent == 1)
         ctxp->last_ccb_indent1 = input_line;
 #endif
+#endif
       return CCB_TK;
     case '[':
       BUILD_OPERATOR (OSB_TK);
Index: parse-scan.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse-scan.y,v
retrieving revision 1.38
diff -u -p -r1.38 parse-scan.y
--- parse-scan.y	2 Feb 2005 18:41:25 -0000	1.38
+++ parse-scan.y	11 Feb 2005 17:37:18 -0000
@@ -42,15 +42,12 @@ definitions and other extensions.  */
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
-#include "input.h"
 #include "obstack.h"
 #include "toplev.h"
 
 extern FILE *finput, *out;
  
-/* Current position in real source file.  */
-
-location_t input_location;
+ const char *main_input_filename;
 
 /* Obstack for the lexer.  */
 struct obstack temporary_obstack;
@@ -1295,7 +1292,7 @@ report_class_declaration (const char * n
       if (!previous_output)
 	{
 	  if (flag_list_filename)
-	    fprintf (out, "%s: ", input_filename);
+	    fprintf (out, "%s: ", main_input_filename);
 	  previous_output = 1;
 	}
 
@@ -1340,7 +1337,7 @@ report (void)
 {
   extern int flag_complexity;
   if (flag_complexity)
-    fprintf (out, "%s %d\n", input_filename, complexity);
+    fprintf (out, "%s %d\n", main_input_filename, complexity);
 }
 
 /* Reset global status used by the report functions.  */
@@ -1357,7 +1354,7 @@ reset_report (void)
 void
 yyerror (const char *msg ATTRIBUTE_UNUSED)
 {
-  fprintf (stderr, "%s: %d: %s\n", input_filename, input_line, msg);
+  fprintf (stderr, "%s: %s\n", main_input_filename, msg);
   exit (1);
 }
 

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