aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/options.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-09-21 08:27:00 +0200
committerTobias Burnus <tobias@codesourcery.com>2021-09-21 08:28:30 +0200
commit417ea5c02cef7f000e66d1af22b066c2c1cda047 (patch)
tree1212ed64ad39e507f11d767384a56c08136a7d36 /gcc/fortran/options.c
parent63c6446f77b9001d26f973114450d790749f282b (diff)
downloadgcc-417ea5c02cef7f000e66d1af22b066c2c1cda047.zip
gcc-417ea5c02cef7f000e66d1af22b066c2c1cda047.tar.gz
gcc-417ea5c02cef7f000e66d1af22b066c2c1cda047.tar.bz2
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.
Diffstat (limited to 'gcc/fortran/options.c')
-rw-r--r--gcc/fortran/options.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 847e20e..d789397 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: