Bug 58334 - preprocessor behavior diffs under line continuation
Summary: preprocessor behavior diffs under line continuation
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.8.1
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 67623 (view as bug list)
Depends on:
Blocks: 28662
  Show dependency treegraph
 
Reported: 2013-09-06 10:20 UTC by Rimvydas (RJ)
Modified: 2021-08-27 11:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-01-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rimvydas (RJ) 2013-09-06 10:20:46 UTC
Sometimes tedious to detect, happens only on continued part of line.
Look like incorrect detection of strings
Not part of std, but depends on placement.

Sample:
$ cat def_test.F90 
program foo
implicit none
character(len=16) :: a,b,c
a="XXX"
b="&
  &XXX"
c="XXX &
  & XXX"
write(0,*) 'a=',a,' b=',b,' c=',c 
endprogram foo

gfortran def_test.F90 -Wall -Wextra -DXXX=program && ./a.out
 a=XXX              b=program          c=XXX  program
Comment 1 Dominique d'Humieres 2014-01-07 13:48:58 UTC
Still present at r206385.
Comment 2 markeggleston 2020-01-09 10:14:10 UTC
Still present at revision 280000 (10.0)
Comment 3 markeggleston 2020-01-09 15:54:03 UTC
Looks like macro expansion is performed in libcpp/traditional.c by the routine _cpp_scan_out_logical_line called by _cpp_read_logical_line_trad.

I'm pretty sure that C style continuations are handled by _cpp_scan_out_logical_line.  Fortran continuations are different (further complicated depending on whether it is free form or fixed form) so the continuation is treated as a new logical line and it assumed that that is no open
quote thus the macro is expanded inside a string.
Comment 4 Andrew Pinski 2021-08-27 02:15:20 UTC
*** Bug 67623 has been marked as a duplicate of this bug. ***
Comment 5 Manuel López-Ibáñez 2021-08-27 11:22:14 UTC
Some useful links copied from the duplicated report:

https://gcc.gnu.org/ml/gcc/2014-11/msg00357.html

See also the comments in https://gcc.gnu.org/ml/gcc/2014-12/msg00003.html and follow-ups.