aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2014-11-11 22:50:48 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2014-11-11 22:50:48 +0000
commit3aa34c1d8f94fc56d66de3b8d09dbd8c2c9e8525 (patch)
tree131a5405db6b77d647e372c65ba2c7ec3a8b9360 /gcc/fortran
parentc256f14362ccf94cbb302145e85fab84531ca61d (diff)
downloadgcc-3aa34c1d8f94fc56d66de3b8d09dbd8c2c9e8525.zip
gcc-3aa34c1d8f94fc56d66de3b8d09dbd8c2c9e8525.tar.gz
gcc-3aa34c1d8f94fc56d66de3b8d09dbd8c2c9e8525.tar.bz2
re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagnostic (pragmas) and color)
libcpp/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * include/line-map.h (linemap_position_for_loc_and_offset): Declare. * line-map.c (linemap_position_for_loc_and_offset): New. gcc/fortran/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * gfortran.h (warn_use_without_only): Remove. (gfc_diagnostics_finish): Declare. * error.c: Include tree-diagnostics.h (gfc_format_decoder): New. (gfc_diagnostics_init): Use gfc_format_decoder. Set default caret char. (gfc_diagnostics_finish): Restore tree diagnostics defaults, but keep gfc_diagnostics_starter and finalizer. Restore default caret. * options.c: Remove all uses of warn_use_without_only. * lang.opt (Wuse-without-only): Add Var. * f95-lang.c (gfc_be_parse_file): Call gfc_diagnostics_finish. * module.c (gfc_use_module): Use gfc_warning_now_2. * parse.c (decode_statement): Likewise. (decode_gcc_attribute): Likewise. (next_free): Likewise. (next_fixed): Likewise. gcc/testsuite/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * lib/gfortran-dg.exp: Update regexp to match locus and message without caret. * gfortran.dg/use_without_only_1.f90: Add column numbers. * gfortran.dg/warnings_are_errors_1.f: Update. From-SVN: r217383
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog20
-rw-r--r--gcc/fortran/error.c45
-rw-r--r--gcc/fortran/f95-lang.c4
-rw-r--r--gcc/fortran/gfortran.h4
-rw-r--r--gcc/fortran/lang.opt2
-rw-r--r--gcc/fortran/module.c5
-rw-r--r--gcc/fortran/options.c5
-rw-r--r--gcc/fortran/parse.c18
8 files changed, 84 insertions, 19 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 7c89d33..7fd573c 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,23 @@
+2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR fortran/44054
+ * gfortran.h (warn_use_without_only): Remove.
+ (gfc_diagnostics_finish): Declare.
+ * error.c: Include tree-diagnostics.h
+ (gfc_format_decoder): New.
+ (gfc_diagnostics_init): Use gfc_format_decoder. Set default caret
+ char.
+ (gfc_diagnostics_finish): Restore tree diagnostics defaults, but
+ keep gfc_diagnostics_starter and finalizer. Restore default caret.
+ * options.c: Remove all uses of warn_use_without_only.
+ * lang.opt (Wuse-without-only): Add Var.
+ * f95-lang.c (gfc_be_parse_file): Call gfc_diagnostics_finish.
+ * module.c (gfc_use_module): Use gfc_warning_now_2.
+ * parse.c (decode_statement): Likewise.
+ (decode_gcc_attribute): Likewise.
+ (next_free): Likewise.
+ (next_fixed): Likewise.
+
2014-11-11 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR fortran/63701
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index 2116f56..cbab731 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "diagnostic-color.h"
+#include "tree-diagnostic.h" /* tree_diagnostics_defaults */
static int suppress_errors = 0;
@@ -958,6 +959,38 @@ gfc_warning_now (const char *gmsgid, ...)
buffer_flag = i;
}
+/* Called from output_format -- during diagnostic message processing
+ to handle Fortran specific format specifiers with the following meanings:
+
+ %C Current locus (no argument)
+*/
+static bool
+gfc_format_decoder (pretty_printer *pp,
+ text_info *text, const char *spec,
+ int precision ATTRIBUTE_UNUSED, bool wide ATTRIBUTE_UNUSED,
+ bool plus ATTRIBUTE_UNUSED, bool hash ATTRIBUTE_UNUSED)
+{
+ switch (*spec)
+ {
+ case 'C':
+ {
+ static const char *result = "(1)";
+ gcc_assert (gfc_current_locus.nextc - gfc_current_locus.lb->line >= 0);
+ unsigned int c1 = gfc_current_locus.nextc - gfc_current_locus.lb->line;
+ gcc_assert (text->locus);
+ *text->locus
+ = linemap_position_for_loc_and_offset (line_table,
+ gfc_current_locus.lb->location,
+ c1);
+ global_dc->caret_char = '1';
+ pp_string (pp, result);
+ return true;
+ }
+ default:
+ return false;
+ }
+}
+
/* Return a malloc'd string describing a location. The caller is
responsible for freeing the memory. */
static char *
@@ -1356,5 +1389,17 @@ gfc_diagnostics_init (void)
{
diagnostic_starter (global_dc) = gfc_diagnostic_starter;
diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
+ diagnostic_format_decoder (global_dc) = gfc_format_decoder;
+ global_dc->caret_char = '^';
+}
+
+void
+gfc_diagnostics_finish (void)
+{
+ tree_diagnostics_defaults (global_dc);
+ /* We still want to use the gfc starter and finalizer, not the tree
+ defaults. */
+ diagnostic_starter (global_dc) = gfc_diagnostic_starter;
+ diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
global_dc->caret_char = '^';
}
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index c313606..223e938 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -230,6 +230,10 @@ gfc_be_parse_file (void)
/* Clear the binding level stack. */
while (!global_bindings_p ())
poplevel (0, 0);
+
+ /* Switch to the default tree diagnostics here, because there may be
+ diagnostics before gfc_finish(). */
+ gfc_diagnostics_finish ();
}
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 00bc840..83d2b1a 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2455,7 +2455,6 @@ typedef struct
int warn_tabs;
int warn_underflow;
int warn_intrinsic_shadow;
- int warn_use_without_only;
int warn_intrinsics_std;
int warn_character_truncation;
int warn_array_temp;
@@ -2691,7 +2690,8 @@ typedef struct gfc_error_buf
} gfc_error_buf;
void gfc_error_init_1 (void);
-void gfc_diagnostics_init(void);
+void gfc_diagnostics_init (void);
+void gfc_diagnostics_finish (void);
void gfc_buffer_error (int);
const char *gfc_print_wide_char (gfc_char_t);
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index b66e892..d6fe603 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -262,7 +262,7 @@ Fortran
; Documented in C/C++
Wuse-without-only
-Fortran Warning
+Fortran Var(warn_use_without_only) Warning
Warn about USE statements that have no ONLY qualifier
Wopenmp-simd
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 1c02070..56351f0 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -6744,8 +6744,9 @@ gfc_use_module (gfc_use_list *module)
only_flag = module->only_flag;
current_intmod = INTMOD_NONE;
- if (!only_flag && gfc_option.warn_use_without_only)
- gfc_warning_now ("USE statement at %C has no ONLY qualifier");
+ if (!only_flag)
+ gfc_warning_now_2 (OPT_Wuse_without_only,
+ "USE statement at %C has no ONLY qualifier");
filename = XALLOCAVEC (char, strlen (module_name) + strlen (MODULE_EXTENSION)
+ 1);
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 8bc8f94..74b4d6d6 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -107,7 +107,6 @@ gfc_init_options (unsigned int decoded_options_count,
gfc_option.warn_tabs = 1;
gfc_option.warn_underflow = 1;
gfc_option.warn_intrinsic_shadow = 0;
- gfc_option.warn_use_without_only = 0;
gfc_option.warn_intrinsics_std = 0;
gfc_option.warn_align_commons = 1;
gfc_option.warn_real_q_constant = 0;
@@ -737,10 +736,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
gfc_option.warn_intrinsic_shadow = value;
break;
- case OPT_Wuse_without_only:
- gfc_option.warn_use_without_only = value;
- break;
-
case OPT_Walign_commons:
gfc_option.warn_align_commons = value;
break;
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 4539beb..f9c1683 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -550,7 +550,7 @@ decode_statement (void)
stored an error message of some sort. */
if (gfc_error_check () == 0)
- gfc_error_now ("Unclassifiable statement at %C");
+ gfc_error_now_2 ("Unclassifiable statement at %C");
reject_statement ();
@@ -797,7 +797,7 @@ decode_gcc_attribute (void)
stored an error message of some sort. */
if (gfc_error_check () == 0)
- gfc_error_now ("Unclassifiable GCC directive at %C");
+ gfc_error_now_2 ("Unclassifiable GCC directive at %C");
reject_statement ();
@@ -836,17 +836,17 @@ next_free (void)
gfc_match_small_literal_int (&i, &cnt);
if (cnt > 5)
- gfc_error_now ("Too many digits in statement label at %C");
+ gfc_error_now_2 ("Too many digits in statement label at %C");
if (i == 0)
- gfc_error_now ("Zero is not a valid statement label at %C");
+ gfc_error_now_2 ("Zero is not a valid statement label at %C");
do
c = gfc_next_ascii_char ();
while (ISDIGIT(c));
if (!gfc_is_whitespace (c))
- gfc_error_now ("Non-numeric character in statement label at %C");
+ gfc_error_now_2 ("Non-numeric character in statement label at %C");
return ST_NONE;
}
@@ -858,7 +858,7 @@ next_free (void)
if (at_bol && gfc_peek_ascii_char () == ';')
{
- gfc_error_now ("Semicolon at %C needs to be preceded by "
+ gfc_error_now_2 ("Semicolon at %C needs to be preceded by "
"statement");
gfc_next_ascii_char (); /* Eat up the semicolon. */
return ST_NONE;
@@ -917,8 +917,8 @@ next_free (void)
if (at_bol && c == ';')
{
if (!(gfc_option.allow_std & GFC_STD_F2008))
- gfc_error_now ("Fortran 2008: Semicolon at %C without preceding "
- "statement");
+ gfc_error_now_2 ("Fortran 2008: Semicolon at %C without preceding "
+ "statement");
gfc_next_ascii_char (); /* Eat up the semicolon. */
return ST_NONE;
}
@@ -1017,7 +1017,7 @@ next_fixed (void)
if (digit_flag)
{
if (label == 0)
- gfc_warning_now ("Zero is not a valid statement label at %C");
+ gfc_warning_now_2 ("Zero is not a valid statement label at %C");
else
{
/* We've found a valid statement label. */