Bug 92091 - Inconsistent diagnostics for INCLUDE vs. #include
Summary: Inconsistent diagnostics for INCLUDE vs. #include
Status: WAITING
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.0
: P5 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-14 20:19 UTC by anlauf
Modified: 2020-07-22 19:52 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 10.0, 7.4.1, 8.3.1, 9.2.1
Last reconfirmed: 2020-07-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description anlauf 2019-10-14 20:19:19 UTC
For files included via INCLUDE, the diagnostics printed may be incomplete
when the included file resides in a different directory.  There is no
problem when using #include.

Reproducer:

% cat bug.f90
module bug
  implicit none
  public
  include 'inc1.f90'
  include 'inc2.f90'
end module bug

# cat bug.F90
module bug
  implicit none
  public
#include "inc1.f90"
#include "inc2.f90"
end module bug

% cat otherdir/inc1.f90
  character*1 c

% cat inc2.f90 
  character*2 d


Using e.g. svn rev.276967, I get:

% gfc-10 -c bug.f90 -Iotherdir -std=f2008
inc1.f90:1:14:

Warning: Obsolescent feature: Old-style character length at (1)
inc2.f90:1:14:

    1 |   character*2 d
      |              1
Warning: Obsolescent feature: Old-style character length at (1)

% gfc-10 -c bug.F90 -Iotherdir -std=f2008
otherdir/inc1.f90:1:14:

    1 |   character*1 c
      |              1
Warning: Obsolescent feature: Old-style character length at (1)
inc2.f90:1:14:

    1 |   character*2 d
      |              1
Warning: Obsolescent feature: Old-style character length at (1)


Note that the diagnostics for inc1.f90 is incomplete for INCLUDE.
Also, the filename does not show the full path in that case.  Not
sure if this is relevant to the issue.

This affects all gcc versions down to at least 7.x, so no regression.
Comment 1 kargls 2019-10-14 21:05:50 UTC
(In reply to anlauf from comment #0)
> For files included via INCLUDE, the diagnostics printed may be incomplete
> when the included file resides in a different directory.  There is no
> problem when using #include.
> 
> Reproducer:
> 
> % cat bug.f90
> module bug
>   implicit none
>   public
>   include 'inc1.f90'
>   include 'inc2.f90'
> end module bug
> 
> # cat bug.F90
> module bug
>   implicit none
>   public
> #include "inc1.f90"
> #include "inc2.f90"
> end module bug
> 
> % cat otherdir/inc1.f90
>   character*1 c
> 
> % cat inc2.f90 
>   character*2 d
> 
> 
> Using e.g. svn rev.276967, I get:
> 
> % gfc-10 -c bug.f90 -Iotherdir -std=f2008
> inc1.f90:1:14:
> 
> Warning: Obsolescent feature: Old-style character length at (1)
> inc2.f90:1:14:
> 
>     1 |   character*2 d
>       |              1
> Warning: Obsolescent feature: Old-style character length at (1)
> 
> % gfc-10 -c bug.F90 -Iotherdir -std=f2008
> otherdir/inc1.f90:1:14:
> 
>     1 |   character*1 c
>       |              1
> Warning: Obsolescent feature: Old-style character length at (1)
> inc2.f90:1:14:
> 
>     1 |   character*2 d
>       |              1
> Warning: Obsolescent feature: Old-style character length at (1)
> 
> 
> Note that the diagnostics for inc1.f90 is incomplete for INCLUDE.
> Also, the filename does not show the full path in that case.  Not
> sure if this is relevant to the issue.
> 

Technical the full path isn't shown for any of your examples.
Comment 2 Dominique d'Humieres 2020-07-22 12:16:31 UTC
See pr94931 for the include path.

Am I correct to understand that #include is handled by the preprocessor?
Comment 3 anlauf 2020-07-22 19:52:16 UTC
(In reply to Dominique d'Humieres from comment #2)
> Am I correct to understand that #include is handled by the preprocessor?

Yes.

Other compilers always show the path to the included file in the warning.
E.g. Intel:

% ifort pr92091.f90 -stand -Iotherdir -c
otherdir/inc1.f90(1): warning #7346: The CHARACTER* form of a CHARACTER declaration is an obsolescent feature in Fortran 2003.
  character*1 c
------------^
inc2.f90(1): warning #7346: The CHARACTER* form of a CHARACTER declaration is an obsolescent feature in Fortran 2003.
  character*2 d
------------^

Similarly for pr92091.F90 .