Hi Tobias,

Am 20.09.21 um 22:33 schrieb Tobias Burnus:
And v3 – I realized that testcases would be useful. Thus, now with added
testcases. :-)

I was about to recommend a testcase I prepared when your revised patch
arrived.  Will not bother you with it, as you seem to provide really
good coverage.

LGTM.

Thanks for the patch!

Harald

Tobias

On 17.09.21 20:45, Tobias Burnus wrote:
I seemingly messed up a bit in previous patch – corrected version
attached.

OK?

Tobias

PS: Due to now enabling the missing-include-dir warning also for
cpp,the following
warning show up during build. This seems to be specific to libgfortran
building,
libgomp works and real-world code also does not seem to be affected:
<built-in>: Error: <instdir>/x86_64-pc-linux-gnu/include: No such file
or directory [-Werror=missing-include-dirs]
<built-in>: Error: <instdir>/x86_64-pc-linux-gnu/sys-include: No such
file or directory [-Werror=missing-include-dirs]
<built-in>: Error: finclude: No such file or directory
[-Werror=missing-include-dirs]

The latter is due to the driver adding '-fintrinsic-modules-path
finclude'
when calling f951. I think the rest is a side effect of running with -B
and other build trickery.

The warnings do not trigger when compiling the Fortran file in libgomp
nor for
a quick real-world case (which uses gfortran in a normal way not with
-B etc.).
Thus, I think it should be fine.
Alternatively, we could think of reducing the noisiness. Thoughts?

PPS: Besides this, the following still applies:

On 17.09.21 15:02, Tobias Burnus wrote:
Short version:
* -Wno-missing-include-dirs  had no effect as the warning was always on
* For CPP-only options like -idirafter, no warning was shown.

This patch tries to address both, i.e. cpp's include-dir diagnostics are
shown as well – and silencing the diagnostic works as well.

OK for mainline?

Tobias

PS:  BACKGROUND and LONG DESCRIPTION

C/C++ by default have disabled the -Wmissing-include-dirs warning.
Fortran by default has that warning enabled.

The value is actually stored at two places (cf. c-family/c.opt):
  Wmissing-include-dirs
  ... CPP(warn_missing_include_dirs)
Var(cpp_warn_missing_include_dirs) Init(0)

For CPP, that value always needs to initialized – and it is used
in gcc/incpath.c as
              cpp_options *opts = cpp_get_options (pfile);
              if (opts->warn_missing_include_dirs &&
cur->user_supplied_p)
                cpp_warning (pfile, CPP_W_MISSING_INCLUDE_DIRS, "%s:
%s",

Additionally, there is cpp_warn_missing_include_dirs which is used by
Fortran – and which consists of
  global_options.x_cpp_warn_missing_include_dirs
  global_options_set._cpp_warn_missing_include_dirs

The flag processing happens as described in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534#c11
in short:
  - First gfc_init_options is called
  - Then for reach command-line option gfc_handle_option
  - Finally gfc_post_options

Currently:
- gfc_init_options: Sets cpp_warn_missing_include_dirs
  (unconditionally as unset)
- gfc_handle_option: Always warns about the missing include dir
- before gfc_post_options: set_option is called, which sets
  cpp_warn_missing_include_dirs – but that's too late.

Additionally, as mentioned above – pfile's warn_missing_include_dirs
is never properly set.

 * * *

This patch fixes those issues:
* Now -Wno-missing-include-dirs does silence the warnings
* CPP now also properly does warn.

Example (initial version):
$ gfortran-trunk ../empty.f90 -c -cpp -idirafter /fdaf/ -I bar/
-Wmissing-include-dirs
f951: Warning: Nonexistent include directory ‘bar//’
[-Wmissing-include-dirs]
<built-in>: Warning: /fdaf/: No such file or directory
<built-in>: Warning: bar/: No such file or directory

In order to avoid the double output for -I, I disabled the Fortran
output if
CPP is enabled. Additionally, I had to use the
cpp_reason_option_codes to
print the flag in brackets.
Fixed/final output is:

<built-in>: Warning: /fdaf/: No such file or directory
[-Wmissing-include-dirs]
<built-in>: Warning: bar/: No such file or directory
[-Wmissing-include-dirs]

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955


Reply via email to