[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2021-09-24 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #16 from CVS Commits  ---
The master branch has been updated by Tobias Burnus :

https://gcc.gnu.org/g:204f56aa65d2496e9f7db86c4aa37d42a336fc5b

commit r12-3877-g204f56aa65d2496e9f7db86c4aa37d42a336fc5b
Author: Tobias Burnus 
Date:   Fri Sep 24 09:30:51 2021 +0200

Fortran: Improve file-reading error diagnostic [PR55534]

PR fortran/55534

gcc/fortran/ChangeLog:

* scanner.c (load_file): Return void, call (gfc_)fatal_error for
all errors.
(include_line, include_stmt, gfc_new_file): Remove exit call
for failed load_file run.

gcc/testsuite/ChangeLog:

* gfortran.dg/include_9.f90: Add dg-prune-output.
* gfortran.dg/include_23.f90: New test.
* gfortran.dg/include_24.f90: New test.

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #15 from CVS Commits  ---
The master branch has been updated by Tobias Burnus :

https://gcc.gnu.org/g:83aac698835edcdb3e6d96b856bef1c5f92e5e24

commit r12-3825-g83aac698835edcdb3e6d96b856bef1c5f92e5e24
Author: Tobias Burnus 
Date:   Wed Sep 22 20:58:35 2021 +0200

Fortran: Improve -Wmissing-include-dirs warnings [PR55534]

It turned out that enabling the -Wmissing-include-dirs for libcpp did
output
too many warnings â at least as run with -B and similar options during
the
GCC build and warning for internal include dirs like finclude, unlikely of
relevance to for a real-world user.
This patch now only warns for -I and -J by default but permits to get the
full warnings including libcpp ones with -Wmissing-include-dirs. It
additionally documents this in the manual.

With that change, the -Wno-missing-include-dirs could be removed
from libgfortran's configure and libgomp's testsuite always cflags.
This reverts those bits of the previous
commit r12-3722-g417ea5c02cef7f000e66d1af22b066c2c1cda047

Additionally, it turned out that all call to load_file called exit
explicitly - except for the main file via gfc_init -> gfc_new_file. The
latter also output a file not existing fatal error, such that two errors
where printed. Now exit is called in line with the other users of
load_file.

Finally, when compileing with "nonexisting/file.f90", first a warning that
"nonexisting" does not exist as include path was printed before the file
not found error was printed. Now the directory in which the physical file
is located is added silently, relying on the file-not-found diagnostic for
those.

PR fortran/55534
gcc/ChangeLog:

* doc/invoke.texi (-Wno-missing-include-dirs.): Document Fortran
behavior.

gcc/fortran/ChangeLog:

* cpp.c (gfc_cpp_register_include_paths, gfc_cpp_post_options):
Add new bool verbose_missing_dir_warn argument.
* cpp.h (gfc_cpp_post_options): Update prototype.
* f95-lang.c (gfc_init): Remove duplicated file-not found diag.
* gfortran.h (gfc_check_include_dirs): Takes bool
verbose_missing_dir_warn arg.
(gfc_new_file): Returns now void.
* options.c (gfc_post_options): Update to warn for -I and -J,
only, by default but for all when user requested.
* scanner.c (gfc_do_check_include_dir):
(gfc_do_check_include_dirs, gfc_check_include_dirs): Take bool
verbose warn arg and update to avoid printing the same message
twice or never.
(load_file): Fix indent.
(gfc_new_file): Return void and exit when load_file failed
as all other load_file users do.

libgfortran/ChangeLog:

* configure.ac (AM_FCFLAGS): Revert r12-3722 by removing
-Wno-missing-include-dirs.
* configure: Regenerate.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/fortran.exp (ALWAYS_CFLAGS): Revert
r12-3722 by removing -Wno-missing-include-dirs.
* testsuite/libgomp.oacc-fortran/fortran.exp (ALWAYS_CFLAGS):
Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/include_14.f90: Add -J testcase and update dg-output.
* gfortran.dg/include_15.f90: Likewise.
* gfortran.dg/include_16.f90: Likewise.
* gfortran.dg/include_17.f90: Likewise.
* gfortran.dg/include_18.f90: Likewise.
* gfortran.dg/include_19.f90: Likewise.

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2021-09-21 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

Tobias Burnus  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #14 from Tobias Burnus  ---
Finally FIXED after 9 years.

Thanks for report + the review Harald.
Thanks to all for the patience.

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2021-09-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #13 from CVS Commits  ---
The master branch has been updated by Tobias Burnus :

https://gcc.gnu.org/g:417ea5c02cef7f000e66d1af22b066c2c1cda047

commit r12-3722-g417ea5c02cef7f000e66d1af22b066c2c1cda047
Author: Tobias Burnus 
Date:   Tue Sep 21 08:27:00 2021 +0200

Fortran: Fix -Wno-missing-include-dirs handling [PR55534]

gcc/fortran/ChangeLog:

PR fortran/55534
* cpp.c: Define GCC_C_COMMON_C for #include "options.h" to make
cpp_reason_option_codes available.
(gfc_cpp_register_include_paths): Make static, set pfile's
warn_missing_include_dirs and move before caller.
(gfc_cpp_init_cb): New, cb code moved from ...
(gfc_cpp_init_0): ... here.
(gfc_cpp_post_options): Call gfc_cpp_init_cb.
(cb_cpp_diagnostic_cpp_option): New. As implemented in c-family
to match CppReason flags to -W... names.
(cb_cpp_diagnostic): Use it to replace single special case.
* cpp.h (gfc_cpp_register_include_paths): Remove as now static.
* gfortran.h (gfc_check_include_dirs): New prototype.
(gfc_add_include_path): Add new bool arg.
* options.c (gfc_init_options): Don't set -Wmissing-include-dirs.
(gfc_post_options): Set it here after commandline processing. Call
gfc_add_include_path with defer_warn=false.
(gfc_handle_option): Call it with defer_warn=true.
* scanner.c (gfc_do_check_include_dir, gfc_do_check_include_dirs,
gfc_check_include_dirs): New. Diagnostic moved from ...
(add_path_to_list): ... here, which came before cmdline processing.
Take additional bool defer_warn argument.
(gfc_add_include_path): Take additional defer_warn arg.
* scanner.h (struct gfc_directorylist): Reorder for alignment
issues,
add new 'bool warn'.

libgfortran/ChangeLog:
PR fortran/55534
* configure.ac (AM_FCFLAGS): Add -Wno-missing-include-dirs.
* configure: Regenerate.

libgomp/ChangeLog:
PR fortran/55534
* testsuite/libgomp.fortran/fortran.exp: Add
-Wno-missing-include-dirs
to ALWAYS_CFLAGS.
* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.

gcc/testsuite/ChangeLog:
* gfortran.dg/include_6.f90: Change dg-error to
dg-warning and update pattern.
* gfortran.dg/include_14.f90: New test.
* gfortran.dg/include_15.f90: New test.
* gfortran.dg/include_16.f90: New test.
* gfortran.dg/include_17.f90: New test.
* gfortran.dg/include_18.f90: New test.
* gfortran.dg/include_19.f90: New test.
* gfortran.dg/include_20.f90: New test.
* gfortran.dg/include_21.f90: New test.

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2021-09-17 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #12 from Tobias Burnus  ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579678.html

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2021-09-17 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #11 from Tobias Burnus  ---
The problem is an ordering problem.


Namely:

* toplev.c calls:
  lang_hooks.init_options (save_decoded_options_count, save_decoded_options);

which in turn is:

gfc_init_options ( 
{
  ...
  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
   cpp_warn_missing_include_dirs, 1);
...
  /* Initialize cpp-related options.  */
  gfc_cpp_init_options (decoded_options_count, decoded_options);
...
}

Thus, cpp_warn_missing_include_dirs is enabled.


Now:
  decode_options (&global_options, &global_options_set, ...
is run, which calls:
  read_cmdline_options (opts, opts_set, ...
  → read_cmdline_option
→ handle_option
  → gfc_handle_option
→ gfc_add_include_path
  → gfc_warning_now

and only afterwards decode_options invokes:
  set_option (...)
which then sets:
  global_options_set->x_... = 1
and
  global_options->x_...  = commandline option.
and disables the already shown warning.

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2019-02-02 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

Dominique d'Humieres  changed:

   What|Removed |Added

   Priority|P3  |P5

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2014-12-29 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #10 from Manuel López-Ibáñez  ---
(In reply to Harald Anlauf from comment #9)
> (In reply to Manuel López-Ibáñez from comment #8)
> > (In reply to Manuel López-Ibáñez from comment #7)
> > > The ideal fix for this would adding a function like:
> > 
> > I forgot about this bug and redid the above from scratch. But this time, I
> > actually tested that it works:
> > https://gcc.gnu.org/ml/fortran/2014-10/msg00019.html
> 
> Has this patch been applied?

An equivalent one has. The remaining problem (I think) is that the warning is
given when -I is processed, so the order of -I and -Wno-missing-include-dirs
matters. In your example, the order should be correct, but the driver
unhelpfully re-orders the command-line as:

f951 xxx.f90 -I /no/such/dir -quiet -dumpbase xxx.f90 "-mtune=generic"
"-march=x86-64" -auxbase xxx -Wno-missing-include-dirs -fintrinsic-modules-path
finclude -o /tmp/ccwz8Va5.s

If I invoke f951 manually, it works:

f951 -Wno-missing-include-dirs ~/xxx.f90 -I /no/such/dir
-Wno-missing-include-dirs

However, if I invoke it like this it doesn't work:

f951 -Wno-missing-include-dirs ~/xxx.f90 -I /no/such/dir
-Wno-missing-include-dirs

because prune_options removes duplicated options by keeping the last one.

Thus, the fix is either to buffer the arguments to -I and process them after
all options have been processed or move just the warning code to such a latter
phase. I'm not sure what is simpler.

This is what the C/C++ FE does (see incpath.c add_path, which is called when -I
is processed and c-opts.c register_include_chains, which is called after
options processing and gives the diagnostics).

Note that this applies to all warnings given by add_path_to_list, since ideally
they should be disabled by "--no-warnings" (aka -w), but currently it depends
on the order they are given.

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2014-12-29 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #9 from Harald Anlauf  ---
(In reply to Manuel López-Ibáñez from comment #8)
> (In reply to Manuel López-Ibáñez from comment #7)
> > The ideal fix for this would adding a function like:
> 
> I forgot about this bug and redid the above from scratch. But this time, I
> actually tested that it works:
> https://gcc.gnu.org/ml/fortran/2014-10/msg00019.html

Has this patch been applied?

I checked r219084.  The bug is still there:

% gfc-trunk -Wno-missing-include-dirs xxx.f90 -I /no/such/dir
f951: Warning: Nonexistent include directory '/no/such/dir'
[-Wmissing-include-dirs]

At least I now see the colors...

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2014-10-04 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #8 from Manuel López-Ibáñez  ---
(In reply to Manuel López-Ibáñez from comment #7)
> The ideal fix for this would adding a function like:

I forgot about this bug and redid the above from scratch. But this time, I
actually tested that it works:
https://gcc.gnu.org/ml/fortran/2014-10/msg00019.html

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2014-09-09 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

Manuel López-Ibáñez  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-09-09
 CC||manu at gcc dot gnu.org
 Depends on||62226
 Ever confirmed|0   |1

--- Comment #7 from Manuel López-Ibáñez  ---
The ideal fix for this would adding a function like:

+bool
+gfc_warning_cmdline (int opt, const char *gmsgid, ...)
+{
+  va_list argp;
+  diagnostic_info diagnostic;
+  bool ret;
+
+  va_start (argp, gmsgid);
+  diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION,
+  DK_WARNING);
+  diagnostic.option_index = opt;
+  ret = report_diagnostic (&diagnostic);
+  va_end (argp);
+  return ret;
+}
+

in error.c. Then calling:

Index: gcc/fortran/scanner.c
===
--- gcc/fortran/scanner.c   (revision 214251)
+++ gcc/fortran/scanner.c   (working copy)
@@ -326,13 +326,13 @@ add_path_to_list (gfc_directorylist **li
   if (errno != ENOENT)
gfc_warning_now ("Include directory \"%s\": %s", path,
 xstrerror(errno));
   else
{
- /* FIXME:  Also support -Wmissing-include-dirs.  */
  if (warn)
-   gfc_warning_now ("Nonexistent include directory \"%s\"", path);
+   gfc_warning_cmdline (OPT_Wmissing_include_dirs,
+"Nonexistent include directory \"%s\"", path);
}
   return;
 }
   else if (!S_ISDIR (st.st_mode))
 {

Then, NOT adding gfc_option.warn_missing_include_dirs, but instead fixing
62226, and simply adding:

Index: gcc/fortran/lang.opt
===
--- gcc/fortran/lang.opt(revision 194167)
+++ gcc/fortran/lang.opt(working copy)
@@ -254,6 +254,10 @@
 Fortran Warning
 Warn on intrinsics not part of the selected standard

+Wmissing-include-dirs
+Fortran Warning
+; Documented in C
+
 Wreal-q-constant
 Fortran Warning
 Warn about real-literal-constants with 'q' exponent-letter

This automatically will give you:

* Setting cpp_opts, even when using #pragma, -Werror= and complicated
combinations.

* Colors!

* Printing [-Wmissing-include-dirs] in the warning message.

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2012-12-13 Thread anlauf at gmx dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534



--- Comment #6 from Harald Anlauf  2012-12-13 21:11:20 
UTC ---

Adding some prints, I found that the crash is probably due to

the actual order of invocation of some functions:



gfc_post_options, which calls gfc_cpp_post_options;

then gfc_cpp_register_include_paths, leading to the crash.



At this time, gfc_init was not yet called.



With -Wno-missing-include-dirs, the execution proceeds thru

gfc_init and then gfc_cpp_init_0, where the callbacks finally

are initialized.


[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2012-12-07 Thread anlauf at gmx dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534



--- Comment #5 from Harald Anlauf  2012-12-07 21:09:50 
UTC ---

(In reply to comment #4)

> * With the patch and the warning activated, the compiler crashes in

> gcc/incpath.c's remove_duplicates for cur->name == "/no/such/dir".



Yes, I get:



f951: internal compiler error: Aborted

0x85ec4b0 crash_signal

../../trunk/gcc/toplev.c:334

0x8b0e334 cpp_diagnostic

../../trunk/libcpp/errors.c:63



62  if (!pfile->cb.error)

63abort ();

64  ret = pfile->cb.error (pfile, level, reason, src_loc, 0, _(msgid), ap);



The callback(?) cb.error is probably not set.


[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2012-12-05 Thread burnus at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534



--- Comment #4 from Tobias Burnus  2012-12-06 
00:04:34 UTC ---

(In reply to comment #3)

> I addition to the patch in comment #2 tried:



That piece I also had, but I forgot to include it in the diff. (I have too many

patches on that tree.





> Now the above warning is gone, but some piece is still missing...



* The "-I/foo/bar" might come before -Wno-missing-include-dirs in

gfc_handle_option; thus, the warning in add_path_to_list doesn't trigger.



* With the patch and the warning activated, the compiler crashes in

gcc/incpath.c's remove_duplicates for cur->name == "/no/such/dir".


[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2012-12-05 Thread anlauf at gmx dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534



--- Comment #3 from Harald Anlauf  2012-12-05 21:43:43 
UTC ---

(In reply to comment #2)

> (See PR 54033 for the patch which originally added this feature.)

> 

> Untested patch.



With this patch, the warning is also gone.  :-)



However, now using the option -Wmissing-include-dirs

yields the message:



f951: warning: command line option '-Wmissing-include-dirs' is valid for

C/C++/ObjC/ObjC++ but not for Fortran [enabled by default]



Which might not be intended, although I can live with it. :-)



I addition to the patch in comment #2 tried:



Index: gcc/fortran/lang.opt

===

--- gcc/fortran/lang.opt(revision 194167)

+++ gcc/fortran/lang.opt(working copy)

@@ -254,6 +254,10 @@

 Fortran Warning

 Warn on intrinsics not part of the selected standard



+Wmissing-include-dirs

+Fortran Warning

+; Documented in C

+

 Wreal-q-constant

 Fortran Warning

 Warn about real-literal-constants with 'q' exponent-letter





Now the above warning is gone, but some piece is still missing...


[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2012-12-05 Thread burnus at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534



Tobias Burnus  changed:



   What|Removed |Added



 CC||burnus at gcc dot gnu.org,

   ||tkoenig at gcc dot gnu.org



--- Comment #2 from Tobias Burnus  2012-12-05 
09:29:08 UTC ---

(See PR 54033 for the patch which originally added this feature.)



Untested patch.



--- a/gcc/fortran/cpp.c

+++ b/gcc/fortran/cpp.c

@@ -471,2 +471,3 @@ gfc_cpp_post_options (void)

   cpp_option->preprocessed = gfc_option.flag_preprocessed;

+  cpp_option->warn_missing_include_dirs =

gfc_option.warn_missing_include_dirs;



diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h

index bf767b2..6f3515f 100644

--- a/gcc/fortran/gfortran.h

+++ b/gcc/fortran/gfortran.h

@@ -2236,2 +2236,3 @@ typedef struct

   int warn_target_lifetime;

+  int warn_missing_include_dirs;

   int max_errors;

diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c

index e05b935..489d1ff 100644

--- a/gcc/fortran/options.c

+++ b/gcc/fortran/options.c

@@ -117,2 +117,3 @@ gfc_init_options (unsigned int decoded_options_count,

   gfc_option.warn_target_lifetime = 0;

+  gfc_option.warn_missing_include_dirs = 0;

   gfc_option.max_errors = 25;

@@ -478,2 +485,3 @@ set_Wall (int setting)

   gfc_option.warn_target_lifetime = setting;

+  gfc_option.warn_missing_include_dirs = setting;



@@ -686,2 +694,6 @@ gfc_handle_option (size_t scode, const char *arg, int

value,



+case OPT_Wmissing_include_dirs:

+  gfc_option.warn_missing_include_dirs = value;

+  break;

+

 case OPT_Wrealloc_lhs:

diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c

index 765c0f9..2bdd87f 100644

--- a/gcc/fortran/scanner.c

+++ b/gcc/fortran/scanner.c

@@ -327,4 +327,3 @@ add_path_to_list (gfc_directorylist **list, const char

*path,

{

- /* FIXME:  Also support -Wmissing-include-dirs.  */

- if (warn)

+ if (warn && gfc_option.warn_missing_include_dirs)

gfc_warning_now ("Nonexistent include directory \"%s\"", path);


[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2012-12-04 Thread anlauf at gmx dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534



--- Comment #1 from Harald Anlauf  2012-12-04 23:02:29 
UTC ---

It would be nice if somebody could explain how to handle the

setting of options.



In the meantime, since this warning may generate lots of output,

I disabled it:



Index: gcc/fortran/scanner.c

===

--- gcc/fortran/scanner.c   (revision 194167)

+++ gcc/fortran/scanner.c   (working copy)

@@ -326,7 +326,7 @@

   else

{

  /* FIXME:  Also support -Wmissing-include-dirs.  */

- if (warn)

+ if (0)

gfc_warning_now ("Nonexistent include directory \"%s\"", path);

}

   return;


[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2012-11-29 Thread anlauf at gmx dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534



Harald Anlauf  changed:



   What|Removed |Added



   Severity|normal  |enhancement