public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about source file location when one uses #line 1 "example2.in" directive
@ 2017-03-14 14:28 Martin Liška
  2017-04-19  8:15 ` Martin Liška
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Liška @ 2017-03-14 14:28 UTC (permalink / raw)
  To: fortran; +Cc: David Malcolm

Hello.

I've been working on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78792, where one provides
#line directive. Problem is that in ipa-profile.c I see:

$ cat ~/Programming/testcases/pr78792.f90
#line 10 "example.in"
PROGRAM example
PRINT *, "example"
END PROGRAM

$ (gdb) p curr_location
$1 = {file = 0x21e2c70 "/home/marxin/Programming/testcases/pr78792.f90", line = 12, column = 0, data = 0x0, sysp = false}

line is fine, however file isn't. The very same source code works fine for *.i files, where file is changed properly.
Can you please help me where to investigate?

Thanks,
Martin

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

* Re: Question about source file location when one uses #line 1 "example2.in" directive
  2017-03-14 14:28 Question about source file location when one uses #line 1 "example2.in" directive Martin Liška
@ 2017-04-19  8:15 ` Martin Liška
  2017-04-19  8:31   ` Thomas Koenig
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Liška @ 2017-04-19  8:15 UTC (permalink / raw)
  To: fortran; +Cc: David Malcolm

Gentle PING^1

> Hello.
>
> I've been working on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78792, where one provides
> #line directive. Problem is that in ipa-profile.c I see:
>
> $ cat ~/Programming/testcases/pr78792.f90
> #line 10 "example.in"
> PROGRAM example
> PRINT *, "example"
> END PROGRAM
>
> $ (gdb) p curr_location
> $1 = {file = 0x21e2c70 "/home/marxin/Programming/testcases/pr78792.f90", line = 12, column = 0, data = 0x0, sysp = false}
>
> line is fine, however file isn't. The very same source code works fine for *.i files, where file is changed properly.
> Can you please help me where to investigate?
>
> Thanks,
> Martin
>

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

* Re: Question about source file location when one uses #line 1 "example2.in" directive
  2017-04-19  8:15 ` Martin Liška
@ 2017-04-19  8:31   ` Thomas Koenig
  2017-04-19 14:18     ` Martin Liška
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Koenig @ 2017-04-19  8:31 UTC (permalink / raw)
  To: fortran

Hello Martin,

>> I've been working on
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78792, where one provides
>> #line directive. Problem is that in ipa-profile.c I see:
>>
>> $ cat ~/Programming/testcases/pr78792.f90
>> #line 10 "example.in"
>> PROGRAM example
>> PRINT *, "example"
>> END PROGRAM

The place to start work on this would probably in scanner.c,
gfc_define_undef_line, which handles lines starting out with #.
I don't see anything there handling #line directives, so this looks
like an obvious place to start.

HTH

	Thomas

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

* Re: Question about source file location when one uses #line 1 "example2.in" directive
  2017-04-19  8:31   ` Thomas Koenig
@ 2017-04-19 14:18     ` Martin Liška
  2017-04-19 15:06       ` Steve Kargl
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Liška @ 2017-04-19 14:18 UTC (permalink / raw)
  To: Thomas Koenig, fortran

On 04/19/2017 10:31 AM, Thomas Koenig wrote:
> Hello Martin,
>
>>> I've been working on
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78792, where one provides
>>> #line directive. Problem is that in ipa-profile.c I see:
>>>
>>> $ cat ~/Programming/testcases/pr78792.f90
>>> #line 10 "example.in"
>>> PROGRAM example
>>> PRINT *, "example"
>>> END PROGRAM
>
> The place to start work on this would probably in scanner.c,
> gfc_define_undef_line, which handles lines starting out with #.
> I don't see anything there handling #line directives, so this looks
> like an obvious place to start.
>
> HTH
>
>     Thomas
>

The place only handles #define and #undefine. Looks there's no place where '#line'
prefix is parsed. To be honest, I'm not able to compile a pre-processed Fortran file:

$ gfortran example2.f90 --coverage -cpp  -E > example.f
$ cat example.f
# 1 "example2.f90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "example2.f90"

# 1 "example2.in" 1

# 1 "inc" 1
# 2 "example2.in" 2




PROGRAM example2
PRINT *, "example2"
END PROGRAM
# 2 "example2.f90" 2


$ gfortran example.f --coverage
example2.in:6:1:

  PROGRAM example2
  1
Error: Non-numeric character in statement label at (1)
example2.in:6:1:
..


Same with adding '-fpreprocessed' option when added.

Thanks,
Martin

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

* Re: Question about source file location when one uses #line 1 "example2.in" directive
  2017-04-19 14:18     ` Martin Liška
@ 2017-04-19 15:06       ` Steve Kargl
  2017-04-26 11:10         ` Martin Liška
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Kargl @ 2017-04-19 15:06 UTC (permalink / raw)
  To: Martin Liška; +Cc: Thomas Koenig, fortran

On Wed, Apr 19, 2017 at 04:18:28PM +0200, Martin Liška wrote:
> prefix is parsed. To be honest, I'm not able to compile a pre-processed Fortran file:
> 
> $ gfortran example2.f90 --coverage -cpp  -E > example.f

> 
> $ gfortran example.f --coverage
> example2.in:6:1:
> 
>   PROGRAM example2
>   1
> Error: Non-numeric character in statement label at (1)
> example2.in:6:1:

You need to understand the filename suffix convention.
A filename ending in .f is assumed to be in fixed-form
format.  A filename ending in .f90 is in free-form
format.  See the gfortran for a complete description
of the filename convention.  If the output of your
first command line does not conform to the fixed-form
format for .f (or free-form format for .f90), then 
gfortran will chock with your second command line.

-- 
Steve
20161221 https://www.youtube.com/watch?v=IbCHE-hONow

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

* Re: Question about source file location when one uses #line 1 "example2.in" directive
  2017-04-19 15:06       ` Steve Kargl
@ 2017-04-26 11:10         ` Martin Liška
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Liška @ 2017-04-26 11:10 UTC (permalink / raw)
  To: sgk; +Cc: Thomas Koenig, fortran

On 04/19/2017 05:06 PM, Steve Kargl wrote:
> On Wed, Apr 19, 2017 at 04:18:28PM +0200, Martin Liška wrote:
>> prefix is parsed. To be honest, I'm not able to compile a pre-processed Fortran file:
>>
>> $ gfortran example2.f90 --coverage -cpp  -E > example.f
> 
>>
>> $ gfortran example.f --coverage
>> example2.in:6:1:
>>
>>   PROGRAM example2
>>   1
>> Error: Non-numeric character in statement label at (1)
>> example2.in:6:1:
> 
> You need to understand the filename suffix convention.
> A filename ending in .f is assumed to be in fixed-form
> format.  A filename ending in .f90 is in free-form
> format.  See the gfortran for a complete description
> of the filename convention.  If the output of your
> first command line does not conform to the fixed-form
> format for .f (or free-form format for .f90), then 
> gfortran will chock with your second command line.
> 

Thanks for clarification, works for me :)
(as one can see here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78792#c3)

Martin

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

end of thread, other threads:[~2017-04-26 11:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14 14:28 Question about source file location when one uses #line 1 "example2.in" directive Martin Liška
2017-04-19  8:15 ` Martin Liška
2017-04-19  8:31   ` Thomas Koenig
2017-04-19 14:18     ` Martin Liška
2017-04-19 15:06       ` Steve Kargl
2017-04-26 11:10         ` Martin Liška

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).