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]
Other format: [Raw text]

RFC - PR java/8608: ICE if WFL not yet set in check_init()


Hi,

  The ICE in PR java/8608 happens because WFL does
not get set before parse_error_context() and thence
issue_warning_error_from_context() is called from
check_init().

WFL is set in check_init() only when
"case EXPR_WITH_FILE_LOCATION" is executed, which
does not happen in the path for the testcase in the
PR.

I could think of the following ways of solving this:

1. Ensure that every expression is wrapped in an EWFL.

2. Make issue_warning_error_from_context() handle an
empty CL (EWFL) argument.

3. If WFL is NULL, wrap the offending declaration in
a suitable EWFL.

#1 solved the PR per-se, but led to other problems
building libjava - the current front-end is too
fragile for this.

#2 makes the diagnostic cursor always be at the last
line of the input file.

#3 is ugly, but at least solves the PR and shows
the correct line number (albeit the wrong column
for multiple variable declarations).

Thoughts on improving this?

Needless to say, I'm not too happy with the attached
patch, but for whatever it is worth, it cleanly
builds libjava and produces no regressions in the
testsuite (including Jacks) on i686-pc-linux-gnu.

The patch does not handle USE_MAPPED_LOCATION as
I am not familiar with it.

OK for mainline if no better suggestions?

Thanks,
Ranjit.

-- 
Ranjit Mathew      Email: rmathew AT gmail DOT com

Bangalore, INDIA.    Web: http://ranjitmathew.hostingzero.com/
Index: ChangeLog
from  Ranjit Mathew  <rmathew@hotmail.com>

	PR java/8608
	* check-init.c (check_init): If WFL is NULL while showing an error
	for a VAR_DECL or a PARM_DECL, create a dummy EXPR_WITH_FILE_LOCATION
	encapsulating it.

Index: check-init.c
===================================================================
--- check-init.c	2005-02-09 16:41:45.000000000 +0530
+++ check-init.c	2005-02-09 17:29:33.000000000 +0530
@@ -516,6 +516,17 @@ check_init (tree exp, words before)
 	      && index >= 0 && ! ASSIGNED_P (before, index))
 	    {
+              /* FIXME: WFL should not be NULL by now, but it could be.  */
+              tree tmp_wfl = wfl;
+              if (!wfl)
+                {
+                  tmp_wfl = build_expr_wfl (NULL_TREE,
+                                            DECL_SOURCE_FILE (exp),
+                                            0,
+                                            0);
+                  EXPR_WFL_SET_LINECOL (tmp_wfl, DECL_SOURCE_LINE (exp), -1);
+                }
+
 	      parse_error_context 
-		(wfl, "Variable %qs may not have been initialized",
+		(tmp_wfl, "Variable %qs may not have been initialized",
 		 IDENTIFIER_POINTER (DECL_NAME (exp)));
 	      /* Suppress further errors. */

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