From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29813 invoked by alias); 24 Sep 2004 02:08:12 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 29704 invoked from network); 24 Sep 2004 02:08:10 -0000 Received: from unknown (HELO mail.codesourcery.com) (65.74.133.10) by sourceware.org with SMTP; 24 Sep 2004 02:08:10 -0000 Received: (qmail 27091 invoked from network); 24 Sep 2004 02:08:09 -0000 Received: from taltos.codesourcery.com (zack@66.92.218.83) by mail.codesourcery.com with DES-CBC3-SHA encrypted SMTP; 24 Sep 2004 02:08:09 -0000 Received: by taltos.codesourcery.com (sSMTP sendmail emulation); Thu, 23 Sep 2004 19:08:09 -0700 To: Per Bothner Cc: gcc@gcc.gnu.org Subject: Re: #pragma interface/implementation broken if --enable-mapped-location References: <41537AFC.4070709@bothner.com> From: Zack Weinberg Date: Fri, 24 Sep 2004 02:22:00 -0000 In-Reply-To: <41537AFC.4070709@bothner.com> (Per Bothner's message of "Thu, 23 Sep 2004 18:40:12 -0700") Message-ID: <87isa4ctbq.fsf@codesourcery.com> User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-09/txt/msg01379.txt.bz2 Per Bothner writes: > 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. We can't take out the cb.line_change call, that will mess up the C front end. My question is why is the pragma_token's location wrong? That would seem to be the real bug. zw