re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$…

re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagnostic (pragmas) and color)

gcc/fortran/ChangeLog:

2014-10-06  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	PR fortran/54687
	* gfortran.h (gfc_warning_cmdline): Add overload that takes an
	option.
	(gfc_error_cmdline): Declare.
	* error.c (gfc_warning_cmdline): New overload that takes an option.
	(gfc_error_cmdline): New.
	* lang.opt (Wmissing-include-dirs): New.
	* scanner.c (add_path_to_list): Use the new functions.
	(load_file): Likewise.
	* options.c (gfc_init_options): Wmissing-include-dirs is enabled
	by default in Fortran.
	(gfc_handle_option): Accept automatically handled options.

From-SVN: r215974
parent 96f6e029
2014-10-06 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/44054
PR fortran/54687
* gfortran.h (gfc_warning_cmdline): Add overload that takes an
option.
(gfc_error_cmdline): Declare.
* error.c (gfc_warning_cmdline): New overload that takes an option.
(gfc_error_cmdline): New.
* lang.opt (Wmissing-include-dirs): New.
* scanner.c (add_path_to_list): Use the new functions.
(load_file): Likewise.
* options.c (gfc_init_options): Wmissing-include-dirs is enabled
by default in Fortran.
(gfc_handle_option): Accept automatically handled options.
2014-10-06 Tobias Burnus <burnus@net-b.de> 2014-10-06 Tobias Burnus <burnus@net-b.de>
* libgfortran.h (GFC_STD_F2015): Add. * libgfortran.h (GFC_STD_F2015): Add.
......
...@@ -1054,15 +1054,51 @@ gfc_diagnostic_finalizer (diagnostic_context *context, ...@@ -1054,15 +1054,51 @@ gfc_diagnostic_finalizer (diagnostic_context *context,
/* Give a warning about the command-line. */ /* Give a warning about the command-line. */
void 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;
}
/* Give a warning about the command-line. */
bool
gfc_warning_cmdline (const char *gmsgid, ...) gfc_warning_cmdline (const char *gmsgid, ...)
{ {
va_list argp; va_list argp;
diagnostic_info diagnostic; diagnostic_info diagnostic;
bool ret;
va_start (argp, gmsgid); va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION, diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION,
DK_WARNING); DK_WARNING);
ret = report_diagnostic (&diagnostic);
va_end (argp);
return ret;
}
/* Give an error about the command-line. */
void
gfc_error_cmdline (const char *gmsgid, ...)
{
va_list argp;
diagnostic_info diagnostic;
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, UNKNOWN_LOCATION, DK_ERROR);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (argp); va_end (argp);
} }
......
...@@ -2698,12 +2698,14 @@ const char *gfc_print_wide_char (gfc_char_t); ...@@ -2698,12 +2698,14 @@ const char *gfc_print_wide_char (gfc_char_t);
void gfc_warning (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); void gfc_warning (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
void gfc_warning_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); void gfc_warning_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
void gfc_warning_cmdline (const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(1,2); bool gfc_warning_cmdline (const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(1,2);
bool gfc_warning_cmdline (int opt, const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(2,3);
void gfc_clear_warning (void); void gfc_clear_warning (void);
void gfc_warning_check (void); void gfc_warning_check (void);
void gfc_error (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); void gfc_error (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
void gfc_error_cmdline (const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(1,2);
void gfc_error_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); void gfc_error_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
......
...@@ -257,6 +257,10 @@ Wintrinsics-std ...@@ -257,6 +257,10 @@ Wintrinsics-std
Fortran Warning Fortran Warning
Warn on intrinsics not part of the selected standard Warn on intrinsics not part of the selected standard
Wmissing-include-dirs
Fortran
; Documented in C/C++
Wuse-without-only Wuse-without-only
Fortran Warning Fortran Warning
Warn about USE statements that have no ONLY qualifier Warn about USE statements that have no ONLY qualifier
......
...@@ -172,6 +172,12 @@ gfc_init_options (unsigned int decoded_options_count, ...@@ -172,6 +172,12 @@ gfc_init_options (unsigned int decoded_options_count,
gfc_option.rtcheck = 0; gfc_option.rtcheck = 0;
gfc_option.coarray = GFC_FCOARRAY_NONE; gfc_option.coarray = GFC_FCOARRAY_NONE;
/* ??? 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. */
if (!global_options_set.x_cpp_warn_missing_include_dirs)
global_options.x_cpp_warn_missing_include_dirs = 1;;
set_default_std_flags (); set_default_std_flags ();
/* Initialize cpp-related options. */ /* Initialize cpp-related options. */
...@@ -634,6 +640,8 @@ gfc_handle_option (size_t scode, const char *arg, int value, ...@@ -634,6 +640,8 @@ gfc_handle_option (size_t scode, const char *arg, int value,
switch (code) switch (code)
{ {
default: default:
if (cl_options[code].flags & gfc_option_lang_mask ())
break;
result = false; result = false;
break; break;
......
...@@ -324,19 +324,16 @@ add_path_to_list (gfc_directorylist **list, const char *path, ...@@ -324,19 +324,16 @@ add_path_to_list (gfc_directorylist **list, const char *path,
if (stat (q, &st)) if (stat (q, &st))
{ {
if (errno != ENOENT) if (errno != ENOENT)
gfc_warning_now ("Include directory \"%s\": %s", path, gfc_warning_cmdline ("Include directory %qs: %s", path,
xstrerror(errno)); xstrerror(errno));
else else if (warn)
{ gfc_warning_cmdline (OPT_Wmissing_include_dirs,
/* FIXME: Also support -Wmissing-include-dirs. */ "Nonexistent include directory %qs", path);
if (warn)
gfc_warning_now ("Nonexistent include directory \"%s\"", path);
}
return; return;
} }
else if (!S_ISDIR (st.st_mode)) else if (!S_ISDIR (st.st_mode))
{ {
gfc_warning_now ("\"%s\" is not a directory", path); gfc_warning_cmdline ("%qs is not a directory", path);
return; return;
} }
...@@ -1925,7 +1922,7 @@ load_file (const char *realfilename, const char *displayedname, bool initial) ...@@ -1925,7 +1922,7 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
input = gfc_open_file (realfilename); input = gfc_open_file (realfilename);
if (input == NULL) if (input == NULL)
{ {
gfc_error_now ("Can't open file '%s'", filename); gfc_error_cmdline ("Can't open file %qs", filename);
return false; return false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment