This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: Re: [PATCH] Postpone __LINE__ evaluation to the end of #line directives
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Max Woodbury <mtewoodbury at gmail dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 28 Nov 2013 22:49:38 +0000
- Subject: Re: Fwd: Re: [PATCH] Postpone __LINE__ evaluation to the end of #line directives
- Authentication-results: sourceware.org; auth=none
- References: <5297C489 dot 2000809 at gmail dot com> <5297C5B6 dot 1000504 at gmail dot com>
On Thu, 28 Nov 2013, Max Woodbury wrote:
> As for the sequence of comments you point to, they are discussing the
> use of __LINE__ in macros, not directives. The standard is quite a bit
> more explicit about token substitution in directives, making it fairly
> clear that substitution is not to occur in directives until
> specifically called for. The elaboration of three distinct forms for
> the '#line' directive with substitution only being called for in the
> third and last form, indicates that something special is intended.
I think the natural reading is that the current token is __LINE__ on the
#line line, because that's what's being macro-expanded, and that the
relevant number of newlines is those strictly before the #line line, so
this directive is expected to make the next line's number that of the
current line (i.e. one less than it would otherwise have been). I think
interpreting it otherwise is what strains the language of the standard.
I think it's completely irrelevant what later parts of the source file are
involved in identifying the form of the directive - the relevant thing is
what is being expanded rather than anything later that was involved in
causing it to be expanded. So, I think this patch is a bad idea, absent
direction otherwise from WG14, and you should raise a DR with WG14 if you
disagree.
--
Joseph S. Myers
joseph@codesourcery.com