Fwd: Re: [PATCH] Postpone __LINE__ evaluation to the end of #line directives
Joseph S. Myers
joseph@codesourcery.com
Fri Nov 29 07:52:00 GMT 2013
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
More information about the Gcc-patches
mailing list