diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-11-11 22:50:48 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-11-11 22:50:48 +0000 |
commit | 766928aa6ac2c846c2d098ef4ef9e220feb4dcab (patch) | |
tree | 131a5405db6b77d647e372c65ba2c7ec3a8b9360 /gcc/fortran/error.c | |
parent | 9fcfed2eb95fea03d967dfcadd1eec9cbab4a744 (diff) |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217383 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/error.c')
-rw-r--r-- | gcc/fortran/error.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index 2116f56ba472..cbab7314ac28 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 = '^'; } |