public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* #pragma interface/implementation broken if --enable-mapped-location
@ 2004-09-24  2:08 Per Bothner
  2004-09-24  2:22 ` Zack Weinberg
  0 siblings, 1 reply; 13+ messages in thread
From: Per Bothner @ 2004-09-24  2:08 UTC (permalink / raw)
  To: gcc

Some change in the last week or so broke support for
#pragma interface/implementation in the --enable-mapped-location
case. This breaks building libjava/java/lang/natClass.cc.

What appears to be happening is this:
The #pragma interface in Class.h is deferred until the current
file (as given by input_location) is natClass.cc.  At that point
cp_lexer_handle_pragma calls cp_lexer_set_source_position_from_token,
which nicely sets the input_location to the saved Class.h.  After a
few more calls we call do_pragms, but with the defer_pragmas flag
turned off, so we get to:

   if (p && (p->is_internal || !CPP_OPTION (pfile, defer_pragmas)))
     {
       /* Since the handler below doesn't get the line number, that it
	 might need for diagnostics, make sure it has the right
	 numbers in place.  */
       if (pfile->cb.line_change)
	(*pfile->cb.line_change) (pfile, pragma_token, false);
       (*p->u.handler) (pfile);
     }

The pragma_token has a location in natClass.cc even though the
original (deferred) pragma was in Class.h.  So the call to
line_change sets the input_location to the location in natClass.cc,
undoing the effect of cp_lexer_set_source_position_from_token.
Hence the #pragma interface doesn't work.

The same thing happens in the --disable-mapped-location case,
but it happens to "accidentally" work:  In that case the cb_line_change
function (in c-lex.c) just changes the input_line, leaving the
input_filename unchanged.  The resulting input_location is
non-sensical, but #pragma interface doesn't care.

My quick-and-dirty fix to remove the cb.line_change call.  I'll try
rebuilding with that.

Zack, how do you want to handle this?
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-09-30  1:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-24  2:08 #pragma interface/implementation broken if --enable-mapped-location Per Bothner
2004-09-24  2:22 ` Zack Weinberg
2004-09-24  2:43   ` Per Bothner
2004-09-24  4:58     ` Zack Weinberg
2004-09-24 14:17       ` Joseph S. Myers
2004-09-24 21:47         ` Zack Weinberg
2004-09-24 22:15           ` Joseph S. Myers
2004-09-24 22:34             ` Zack Weinberg
2004-09-29 19:24           ` Per Bothner
2004-09-29 20:56             ` Zack Weinberg
2004-09-29 21:57               ` Matt Austern
2004-09-29 22:50                 ` Zack Weinberg
2004-09-30  7:57               ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).