re PR java/15543 ("jv-scan --complexity" segfaults)
authorPer Bothner <per@bothner.com>
Sat, 12 Feb 2005 06:12:40 +0000 (22:12 -0800)
committerPer Bothner <bothner@gcc.gnu.org>
Sat, 12 Feb 2005 06:12:40 +0000 (22:12 -0800)
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.

From-SVN: r94928

gcc/java/ChangeLog
gcc/java/jv-scan.c
gcc/java/lex.c
gcc/java/parse-scan.y

index a24d4a4903749a44e01689e3f3c1114d0e13518c..a1002f15b31167896e287b18985fb9baf70ad5c4 100644 (file)
@@ -1,3 +1,14 @@
+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.
+
 2005-02-09  Richard Henderson  <rth@redhat.com>
 
        * builtins.c (initialize_builtins): Call build_common_builtin_nodes.
index 5f90ee93392d00c531de5ca8cc51a598f7ca14b2..b7b8809b1172940fa3cfb22ed3fb51c5f734d47f 100644 (file)
@@ -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 712ffc2c589ad65a4a97439b78af857980b4c89b..d0a8f93e49501783270174fe2577d9217648bbf4 100644 (file)
@@ -108,10 +108,12 @@ java_init_lex (FILE *finput, const char *encoding)
 
   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)
@@ -134,7 +136,9 @@ java_init_lex (FILE *finput, const char *encoding)
   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,28 +1475,28 @@ 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;
 #else
       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;
 #else
       if (ctxp->ccb_indent == 1)
         ctxp->last_ccb_indent1 = input_line;
+#endif
 #endif
       return CCB_TK;
     case '[':
index 189ee728e124fdf176e67eba66b820ade010f854..2e020c800e1f0b155615f10be562ef04cf1b2ac6 100644 (file)
@@ -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 * name)
       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);
 }