public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3722] Fortran: Fix -Wno-missing-include-dirs handling [PR55534]
@ 2021-09-21  6:28 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-09-21  6:28 UTC (permalink / raw)
  To: gcc-cvs

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

commit r12-3722-g417ea5c02cef7f000e66d1af22b066c2c1cda047
Author: Tobias Burnus <tobias@codesourcery.com>
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.

Diff:
---
 gcc/fortran/cpp.c                                  | 106 +++++++++++++--------
 gcc/fortran/cpp.h                                  |   2 -
 gcc/fortran/gfortran.h                             |   3 +-
 gcc/fortran/options.c                              |  24 ++---
 gcc/fortran/scanner.c                              |  82 ++++++++++++----
 gcc/fortran/scanner.h                              |   2 +-
 gcc/testsuite/gfortran.dg/include_14.f90           |   5 +
 gcc/testsuite/gfortran.dg/include_15.f90           |   5 +
 gcc/testsuite/gfortran.dg/include_16.f90           |   2 +
 gcc/testsuite/gfortran.dg/include_17.f90           |   4 +
 gcc/testsuite/gfortran.dg/include_18.f90           |   3 +
 gcc/testsuite/gfortran.dg/include_19.f90           |   4 +
 gcc/testsuite/gfortran.dg/include_20.f90           |   5 +
 gcc/testsuite/gfortran.dg/include_21.f90           |  26 +++++
 gcc/testsuite/gfortran.dg/include_6.f90            |   2 +-
 libgfortran/configure                              |   2 +-
 libgfortran/configure.ac                           |   2 +-
 libgomp/testsuite/libgomp.fortran/fortran.exp      |   3 +
 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp |   3 +
 19 files changed, 206 insertions(+), 79 deletions(-)

diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
index 83c4517acdb..3ff895455e9 100644
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -19,11 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+
+#define GCC_C_COMMON_C
+#include "options.h"  /* For cpp_reason_option_codes. */
+#undef GCC_C_COMMON_C
+
 #include "target.h"
 #include "gfortran.h"
 #include "diagnostic.h"
 
-
 #include "toplev.h"
 
 #include "../../libcpp/internal.h"
@@ -240,6 +244,18 @@ gfc_cpp_temporary_file (void)
   return gfc_cpp_option.temporary_filename;
 }
 
+static void
+gfc_cpp_register_include_paths (void)
+{
+  int cxx_stdinc = 0;
+  cpp_get_options (cpp_in)->warn_missing_include_dirs
+    = global_options.x_cpp_warn_missing_include_dirs;
+  register_include_chains (cpp_in, gfc_cpp_option.sysroot,
+			   gfc_cpp_option.prefix, gfc_cpp_option.multilib,
+			   gfc_cpp_option.standard_include_paths, cxx_stdinc,
+			   gfc_cpp_option.verbose);
+}
+
 void
 gfc_cpp_init_options (unsigned int decoded_options_count,
 		      struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
@@ -435,6 +451,37 @@ gfc_cpp_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED
   return result;
 }
 
+/* This function needs to be called before gfc_cpp_register_include_paths
+   as the latter may diagnose missing include directories.  */
+static void
+gfc_cpp_init_cb (void)
+{
+  struct cpp_callbacks *cb;
+
+  cb = cpp_get_callbacks (cpp_in);
+  cb->file_change = cb_file_change;
+  cb->line_change = cb_line_change;
+  cb->ident = cb_ident;
+  cb->def_pragma = cb_def_pragma;
+  cb->diagnostic = cb_cpp_diagnostic;
+
+  if (gfc_cpp_option.dump_includes)
+    cb->include = cb_include;
+
+  if ((gfc_cpp_option.dump_macros == 'D')
+      || (gfc_cpp_option.dump_macros == 'N'))
+    {
+      cb->define = cb_define;
+      cb->undef  = cb_undef;
+    }
+
+  if (gfc_cpp_option.dump_macros == 'U')
+    {
+      cb->before_define = dump_queued_macros;
+      cb->used_define = cb_used_define;
+      cb->used_undef = cb_used_undef;
+    }
+}
 
 void
 gfc_cpp_post_options (void)
@@ -498,6 +545,7 @@ gfc_cpp_post_options (void)
      way libcpp will do it, namely, with no charset conversion but with
      skipping of a UTF-8 BOM if present.  */
   diagnostic_initialize_input_context (global_dc, nullptr, true);
+  gfc_cpp_init_cb ();
 
   gfc_cpp_register_include_paths ();
 }
@@ -506,32 +554,6 @@ gfc_cpp_post_options (void)
 void
 gfc_cpp_init_0 (void)
 {
-  struct cpp_callbacks *cb;
-
-  cb = cpp_get_callbacks (cpp_in);
-  cb->file_change = cb_file_change;
-  cb->line_change = cb_line_change;
-  cb->ident = cb_ident;
-  cb->def_pragma = cb_def_pragma;
-  cb->diagnostic = cb_cpp_diagnostic;
-
-  if (gfc_cpp_option.dump_includes)
-    cb->include = cb_include;
-
-  if ((gfc_cpp_option.dump_macros == 'D')
-      || (gfc_cpp_option.dump_macros == 'N'))
-    {
-      cb->define = cb_define;
-      cb->undef  = cb_undef;
-    }
-
-  if (gfc_cpp_option.dump_macros == 'U')
-    {
-      cb->before_define = dump_queued_macros;
-      cb->used_define = cb_used_define;
-      cb->used_undef = cb_used_undef;
-    }
-
   /* Initialize the print structure.  Setting print.src_line to -1 here is
      a trick to guarantee that the first token of the file will cause
      a linemarker to be output by maybe_print_line.  */
@@ -723,17 +745,6 @@ gfc_cpp_add_include_path_after (char *path, bool user_supplied)
   add_path (path, INC_AFTER, cxx_aware, user_supplied);
 }
 
-void
-gfc_cpp_register_include_paths (void)
-{
-  int cxx_stdinc = 0;
-  register_include_chains (cpp_in, gfc_cpp_option.sysroot,
-			   gfc_cpp_option.prefix, gfc_cpp_option.multilib,
-			   gfc_cpp_option.standard_include_paths, cxx_stdinc,
-			   gfc_cpp_option.verbose);
-}
-
-
 
 static void scan_translation_unit_trad (cpp_reader *);
 static void account_for_newlines (const unsigned char *, size_t);
@@ -1043,6 +1054,21 @@ cb_used_define (cpp_reader *pfile, location_t line ATTRIBUTE_UNUSED,
   cpp_define_queue = q;
 }
 
+/* Return the gcc option code associated with the reason for a cpp
+   message, or 0 if none.  */
+
+static int
+cb_cpp_diagnostic_cpp_option (enum cpp_warning_reason reason)
+{
+  const struct cpp_reason_option_codes_t *entry;
+
+  for (entry = cpp_reason_option_codes; entry->reason != CPP_W_NONE; entry++)
+    if (entry->reason == reason)
+      return entry->option_code;
+  return 0;
+}
+
+
 /* Callback from cpp_error for PFILE to print diagnostics from the
    preprocessor.  The diagnostic is of type LEVEL, with REASON set
    to the reason code if LEVEL is represents a warning, at location
@@ -1089,8 +1115,8 @@ cb_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
     }
   diagnostic_set_info_translated (&diagnostic, msg, ap,
 				  richloc, dlevel);
-  if (reason == CPP_W_WARNING_DIRECTIVE)
-    diagnostic_override_option_index (&diagnostic, OPT_Wcpp);
+  diagnostic_override_option_index (&diagnostic,
+				    cb_cpp_diagnostic_cpp_option (reason));
   ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
   if (level == CPP_DL_WARNING_SYSHDR)
     global_dc->dc_warn_system_headers = save_warn_system_headers;
diff --git a/gcc/fortran/cpp.h b/gcc/fortran/cpp.h
index f642c7745f7..5cb7e5a9c34 100644
--- a/gcc/fortran/cpp.h
+++ b/gcc/fortran/cpp.h
@@ -50,6 +50,4 @@ void gfc_cpp_done (void);
 void gfc_cpp_add_include_path (char *path, bool user_supplied);
 void gfc_cpp_add_include_path_after (char *path, bool user_supplied);
 
-void gfc_cpp_register_include_paths (void);
-
 #endif /* GFC_CPP_H */
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 8b91225d659..3c7a8434d07 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -3029,9 +3029,10 @@ match gfc_get_pdt_instance (gfc_actual_arglist *, gfc_symbol **,
 void gfc_scanner_done_1 (void);
 void gfc_scanner_init_1 (void);
 
-void gfc_add_include_path (const char *, bool, bool, bool);
+void gfc_add_include_path (const char *, bool, bool, bool, bool);
 void gfc_add_intrinsic_modules_path (const char *);
 void gfc_release_include_path (void);
+void gfc_check_include_dirs (void);
 FILE *gfc_open_included_file (const char *, bool, bool);
 
 int gfc_at_end (void);
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 847e20e8829..d789397515a 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -159,14 +159,7 @@ gfc_init_options (unsigned int decoded_options_count,
 			   | GFC_FPE_UNDERFLOW;
   gfc_option.rtcheck = 0;
 
-  /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
-     enabled by default in Fortran.  Ideally, we should express this
-     in .opt, but that is not supported yet.  */
-  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
-		       cpp_warn_missing_include_dirs, 1);
-
   set_dec_flags (0);
-
   set_default_std_flags ();
 
   /* Initialize cpp-related options.  */
@@ -260,6 +253,13 @@ gfc_post_options (const char **pfilename)
   char *source_path;
   int i;
 
+  /* This needs to be after the commandline has been processed.
+     In Fortran, the options is by default enabled, in C/C++
+     by default disabled.  */
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+		       cpp_warn_missing_include_dirs, 1);
+  gfc_check_include_dirs ();
+
   /* Finalize DEC flags.  */
   post_dec_flags (flag_dec);
 
@@ -339,10 +339,10 @@ gfc_post_options (const char **pfilename)
       source_path = (char *) alloca (i + 1);
       memcpy (source_path, canon_source_file, i);
       source_path[i] = 0;
-      gfc_add_include_path (source_path, true, true, true);
+      gfc_add_include_path (source_path, true, true, true, false);
     }
   else
-    gfc_add_include_path (".", true, true, true);
+    gfc_add_include_path (".", true, true, true, false);
 
   if (canon_source_file != gfc_source_file)
     free (CONST_CAST (char *, canon_source_file));
@@ -511,7 +511,7 @@ gfc_handle_module_path_options (const char *arg)
   gfc_option.module_dir = XCNEWVEC (char, strlen (arg) + 2);
   strcpy (gfc_option.module_dir, arg);
 
-  gfc_add_include_path (gfc_option.module_dir, true, false, true);
+  gfc_add_include_path (gfc_option.module_dir, true, false, true, true);
 
   strcat (gfc_option.module_dir, "/");
 }
@@ -690,7 +690,7 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
 	 with intrinsic modules.  Do no warn because during testing
 	 without an installed compiler, we would get lots of bogus
 	 warnings for a missing include directory.  */
-      gfc_add_include_path (arg, false, false, false);
+      gfc_add_include_path (arg, false, false, false, true);
 
       gfc_add_intrinsic_modules_path (arg);
       break;
@@ -737,7 +737,7 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_I:
-      gfc_add_include_path (arg, true, false, true);
+      gfc_add_include_path (arg, true, false, true, true);
       break;
 
     case OPT_J:
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 39db0994b62..6fe74bd5b8d 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -298,17 +298,69 @@ gfc_scanner_done_1 (void)
     }
 }
 
+static bool
+gfc_do_check_include_dir (const char *path, bool warn)
+{
+  struct stat st;
+  if (stat (path, &st))
+    {
+      if (errno != ENOENT)
+	gfc_warning_now (0, "Include directory %qs: %s",
+			 path, xstrerror(errno));
+      else if (warn && !gfc_cpp_enabled ())
+	  gfc_warning_now (OPT_Wmissing_include_dirs,
+			     "Nonexistent include directory %qs", path);
+      return false;
+    }
+  else if (!S_ISDIR (st.st_mode))
+    {
+      gfc_fatal_error ("%qs is not a directory", path);
+      return false;
+    }
+  return true;
+}
+
+/* In order that -W(no-)missing-include-dirs works, the diagnostic can only be
+   run after processing the commandline.  */
+static void
+gfc_do_check_include_dirs (gfc_directorylist **list)
+{
+  gfc_directorylist *prev, *q, *n;
+  prev = NULL;
+  n = *list;
+  while (n)
+    {
+      q = n; n = n->next;
+      if (gfc_do_check_include_dir (q->path, q->warn))
+	{
+	  prev = q;
+	  continue;
+	}
+      if (prev == NULL)
+	*list = n;
+      else
+	prev->next = n;
+      free (q->path);
+      free (q);
+    }
+}
+
+void
+gfc_check_include_dirs ()
+{
+  gfc_do_check_include_dirs (&include_dirs);
+  gfc_do_check_include_dirs (&intrinsic_modules_dirs);
+}
 
 /* Adds path to the list pointed to by list.  */
 
 static void
 add_path_to_list (gfc_directorylist **list, const char *path,
-		  bool use_for_modules, bool head, bool warn)
+		  bool use_for_modules, bool head, bool warn, bool defer_warn)
 {
   gfc_directorylist *dir;
   const char *p;
   char *q;
-  struct stat st;
   size_t len;
   int i;
   
@@ -326,21 +378,8 @@ add_path_to_list (gfc_directorylist **list, const char *path,
   while (i >=0 && IS_DIR_SEPARATOR (q[i]))
     q[i--] = '\0';
 
-  if (stat (q, &st))
-    {
-      if (errno != ENOENT)
-	gfc_warning_now (0, "Include directory %qs: %s", path,
-			 xstrerror(errno));
-      else if (warn)
-	gfc_warning_now (OPT_Wmissing_include_dirs,
-			 "Nonexistent include directory %qs", path);
-      return;
-    }
-  else if (!S_ISDIR (st.st_mode))
-    {
-      gfc_fatal_error ("%qs is not a directory", path);
-      return;
-    }
+  if (!defer_warn && !gfc_do_check_include_dir (q, warn))
+    return;
 
   if (head || *list == NULL)
     {
@@ -362,17 +401,20 @@ add_path_to_list (gfc_directorylist **list, const char *path,
   if (head)
     *list = dir;
   dir->use_for_modules = use_for_modules;
+  dir->warn = warn;
   dir->path = XCNEWVEC (char, strlen (p) + 2);
   strcpy (dir->path, p);
   strcat (dir->path, "/");	/* make '/' last character */
 }
 
+/* defer_warn is set to true while parsing the commandline.  */
 
 void
 gfc_add_include_path (const char *path, bool use_for_modules, bool file_dir,
-		      bool warn)
+		      bool warn, bool defer_warn)
 {
-  add_path_to_list (&include_dirs, path, use_for_modules, file_dir, warn);
+  add_path_to_list (&include_dirs, path, use_for_modules, file_dir, warn,
+		    defer_warn);
 
   /* For '#include "..."' these directories are automatically searched.  */
   if (!file_dir)
@@ -383,7 +425,7 @@ gfc_add_include_path (const char *path, bool use_for_modules, bool file_dir,
 void
 gfc_add_intrinsic_modules_path (const char *path)
 {
-  add_path_to_list (&intrinsic_modules_dirs, path, true, false, false);
+  add_path_to_list (&intrinsic_modules_dirs, path, true, false, false, false);
 }
 
 
diff --git a/gcc/fortran/scanner.h b/gcc/fortran/scanner.h
index 0bad63f4ffb..8782fe6ccc5 100644
--- a/gcc/fortran/scanner.h
+++ b/gcc/fortran/scanner.h
@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3.  If not see
 typedef struct gfc_directorylist
 {
   char *path;
-  bool use_for_modules;
   struct gfc_directorylist *next;
+  bool use_for_modules, warn;
 }
 gfc_directorylist;
 
diff --git a/gcc/testsuite/gfortran.dg/include_14.f90 b/gcc/testsuite/gfortran.dg/include_14.f90
new file mode 100644
index 00000000000..b306b2c813b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_14.f90
@@ -0,0 +1,5 @@
+! { dg-additional-options "-cpp -idirafter /fdaf/ -I bar" }
+end
+
+! { dg-warning "/fdaf/: No such file or directory" "" { target *-*-* } 0 }
+! { dg-warning "bar: No such file or directory" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/include_15.f90 b/gcc/testsuite/gfortran.dg/include_15.f90
new file mode 100644
index 00000000000..4944282f931
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_15.f90
@@ -0,0 +1,5 @@
+! { dg-additional-options "-cpp -idirafter /fdaf/ -I bar -Wmissing-include-dirs" }
+end
+
+! { dg-warning "/fdaf/: No such file or directory" "" { target *-*-* } 0 }
+! { dg-warning "bar: No such file or directory" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/include_16.f90 b/gcc/testsuite/gfortran.dg/include_16.f90
new file mode 100644
index 00000000000..45794f28e73
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_16.f90
@@ -0,0 +1,2 @@
+! { dg-additional-options "-cpp -idirafter /fdaf/ -I bar -Wno-missing-include-dirs" }
+end
diff --git a/gcc/testsuite/gfortran.dg/include_17.f90 b/gcc/testsuite/gfortran.dg/include_17.f90
new file mode 100644
index 00000000000..0ed5c86d323
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_17.f90
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! { dg-options "-I foo-bar -Wno-missing-include-dirs" }
+end 
+
diff --git a/gcc/testsuite/gfortran.dg/include_18.f90 b/gcc/testsuite/gfortran.dg/include_18.f90
new file mode 100644
index 00000000000..ca69df382fe
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_18.f90
@@ -0,0 +1,3 @@
+! { dg-do compile }
+! { dg-options "-I nothere -Wno-missing-include-dirs" }
+end 
diff --git a/gcc/testsuite/gfortran.dg/include_19.f90 b/gcc/testsuite/gfortran.dg/include_19.f90
new file mode 100644
index 00000000000..2a068174b7e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_19.f90
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! { dg-options "-J foobar/foo -Wno-missing-include-dirs" }
+program main
+end program main
diff --git a/gcc/testsuite/gfortran.dg/include_20.f90 b/gcc/testsuite/gfortran.dg/include_20.f90
new file mode 100644
index 00000000000..4f8fdc6b786
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_20.f90
@@ -0,0 +1,5 @@
+! { dg-do compile }
+! { dg-options "-J foobar/foo" }
+program main
+end program main
+! { dg-warning "Nonexistent include directory" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/include_21.f90 b/gcc/testsuite/gfortran.dg/include_21.f90
new file mode 100644
index 00000000000..40bc5986f7b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/include_21.f90
@@ -0,0 +1,26 @@
+# 1 "../../../trunk/libgfortran/generated/_abs_c4.F90"
+# 1 "C:\\msys\\1.0.10\\home\\FX\\ibin\\i586-pc-mingw32\\libgfortran//"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "../../../trunk/libgfortran/generated/_abs_c4.F90"
+!   Comment here
+
+# 1 "./config.h" 1
+
+# 37 "../../../trunk/libgfortran/generated/_abs_c4.F90" 2
+
+# 1 "./kinds.inc" 1
+# 38 "../../../trunk/libgfortran/generated/_abs_c4.F90" 2
+
+# 1 "./c99_protos.inc" 1
+# 39 "../../../trunk/libgfortran/generated/_abs_c4.F90" 2
+
+elemental function abs_c4 (parm)
+   complex (kind=4), intent (in) :: parm
+   real (kind=4) :: abs_c4
+
+   abs_c4 = abs (parm)
+end function
+
+! { dg-do compile }
+! { dg-options "-fpreprocessed -g3 -Wno-missing-include-dirs" }
diff --git a/gcc/testsuite/gfortran.dg/include_6.f90 b/gcc/testsuite/gfortran.dg/include_6.f90
index f5bb085d321..3e3be1b7bd5 100644
--- a/gcc/testsuite/gfortran.dg/include_6.f90
+++ b/gcc/testsuite/gfortran.dg/include_6.f90
@@ -1,6 +1,6 @@
 ! { dg-do compile }
 ! { dg-options "-I gfortran.log" }
-! { dg-error "is not a directory" "" { target *-*-* } 0 }
+! { dg-warning "Include directory 'gfortran.log/': Not a directory" "" { target *-*-* } 0 }
 ! { dg-prune-output "compilation terminated." }
 end 
 
diff --git a/libgfortran/configure b/libgfortran/configure
index 4810b9b032e..350159aa4fe 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -5985,7 +5985,7 @@ fi
 
 # Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
 if test "x$GCC" = "xyes"; then
-  AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
+  AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring -Wno-missing-include-dirs"
   ## We like to use C11 and C99 routines when available.  This makes
   ## sure that
   ## __STDC_VERSION__ is set such that libc includes make them available.
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index a77509801e6..a3550b4e5d0 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -146,7 +146,7 @@ AM_PROG_CC_C_O
 
 # Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
 if test "x$GCC" = "xyes"; then
-  AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
+  AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring -Wno-missing-include-dirs"
   ## We like to use C11 and C99 routines when available.  This makes
   ## sure that
   ## __STDC_VERSION__ is set such that libc includes make them available.
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index eb701311b6a..912dd2a743e 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -20,6 +20,9 @@ dg-init
 
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+# Silence warnings due to explicitly passed but nonexisting
+# -isystem <instdir>/target>/{sys-,}include (gfortran warns by default)
+lappend ALWAYS_CFLAGS "additional_flags=-Wno-missing-include-dirs"
 
 if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 7365b320668..22e91eca256 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -22,6 +22,9 @@ dg-init
 
 # Turn on OpenACC.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
+# Silence warnings due to explicitly passed but nonexisting
+# -isystem <instdir>/target>/{sys-,}include (gfortran warns by default)
+lappend ALWAYS_CFLAGS "additional_flags=-Wno-missing-include-dirs"
 
 if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-21  6:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21  6:28 [gcc r12-3722] Fortran: Fix -Wno-missing-include-dirs handling [PR55534] Tobias Burnus

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