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]

Re: Fwd: Re: [PATCH] Postpone __LINE__ evaluation to the end of #line directives


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


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