diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-02 19:28:05 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-02 19:28:05 +0000 |
commit | 9d63dbe6b454a33381a73e1ca93aff85b0594f05 (patch) | |
tree | f8a1cb507af3e7ceb424d8056fc0f50558e9cd28 /gcc/diagnostic.c | |
parent | f98abc094eceacf320655d4f16c9f71243455544 (diff) | |
download | gcc-9d63dbe6b454a33381a73e1ca93aff85b0594f05.tar.gz |
2008-03-02 Basile Starynkevitch <basile@starynkevitch.net>
merged with trunk 132817
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@132818 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index c05a8ccc415..bdc5ca5053b 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -1,5 +1,5 @@ /* Language-independent diagnostic subroutines for the GNU Compiler Collection - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis <gdr@codesourcery.com> @@ -159,10 +159,8 @@ diagnostic_build_prefix (diagnostic_info *diagnostic) return (s.file == NULL ? build_message_string ("%s: %s", progname, text) -#ifdef USE_MAPPED_LOCATION : flag_show_column && s.column != 0 ? build_message_string ("%s:%d:%d: %s", s.file, s.line, s.column, text) -#endif : build_message_string ("%s:%d: %s", s.file, s.line, text)); } @@ -273,7 +271,7 @@ diagnostic_report_current_function (diagnostic_context *context, void diagnostic_report_current_module (diagnostic_context *context) { - struct file_stack *p; + const struct line_map *map; if (pp_needs_newline (context->printer)) { @@ -281,23 +279,29 @@ diagnostic_report_current_module (diagnostic_context *context) pp_needs_newline (context->printer) = false; } - p = input_file_stack; - if (p && diagnostic_last_module_changed (context)) + if (input_location <= BUILTINS_LOCATION) + return; + + map = linemap_lookup (line_table, input_location); + if (map && diagnostic_last_module_changed (context, map)) { - expanded_location xloc = expand_location (p->location); - pp_verbatim (context->printer, - "In file included from %s:%d", - xloc.file, xloc.line); - while ((p = p->next) != NULL) + diagnostic_set_last_module (context, map); + if (! MAIN_FILE_P (map)) { - xloc = expand_location (p->location); + map = INCLUDED_FROM (line_table, map); pp_verbatim (context->printer, - ",\n from %s:%d", - xloc.file, xloc.line); + "In file included from %s:%d", + map->to_file, LAST_SOURCE_LINE (map)); + while (! MAIN_FILE_P (map)) + { + map = INCLUDED_FROM (line_table, map); + pp_verbatim (context->printer, + ",\n from %s:%d", + map->to_file, LAST_SOURCE_LINE (map)); + } + pp_verbatim (context->printer, ":"); + pp_newline (context->printer); } - pp_verbatim (context->printer, ":"); - diagnostic_set_last_module (context); - pp_newline (context->printer); } } @@ -542,11 +546,31 @@ pedwarn (const char *gmsgid, ...) va_start (ap, gmsgid); diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, - pedantic_error_kind ()); + pedantic_warning_kind ()); + report_diagnostic (&diagnostic); + va_end (ap); +} + +/* A "permissive" error: issues an error unless -fpermissive was given + on the command line, in which case it issues a warning. Use this + for things that really should be errors but we want to support + legacy code. */ + +void +permerror (const char *gmsgid, ...) +{ + diagnostic_info diagnostic; + va_list ap; + + va_start (ap, gmsgid); + diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, + permissive_error_kind ()); + diagnostic.option_index = OPT_fpermissive; report_diagnostic (&diagnostic); va_end (ap); } + /* A hard error: the code is definitely ill-formed, and an object file will not be produced. */ void |