From 9a472a42247d099c512b6d992890f88643612c8c Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Sat, 28 Jun 2003 16:23:29 +0000 Subject: [PATCH] diagnostic.h (diagnostic_set_info): Replace file and lineno parameters with a location_t. * diagnostic.h (diagnostic_set_info): Replace file and lineno parameters with a location_t. * diagnostic.c (diagnostic_set_info): Replace file and lineno parameters with a location_t. (inform, warning, pedwarn, error, sorry, fatal_error, internal_error, warning_with_decl, pedwarn_with_decl, error_with_decl): Adjust. * c-error.c (pedwarn_c99): Adjust. * c-format.c (status_warning): Adjust. * rtl-error.c (file_and_line_for_asm): Rename to ... (location_for_asm): Return a location_t. (diagnostic_for_asm): Adjust. * cp/cp-tree.h (cp_line_of, cp_file_of): Remove. * cp/error.c (cp_line_of, cp_file_of): Merge into ... (location_of): ... here. Make static, return a location_t. (cp_error_at, cp_warning_at, cp_pedwarn_at): Adjust. * testsuite/g++.old-deja/g++.robertl/eb133.C: Set expected line number. * testsuite/g++.old-deja/g++.robertl/eb133a.C: Likewise. * testsuite/g++.old-deja/g++.robertl/eb133b.C: Likewise. From-SVN: r68643 --- gcc/ChangeLog | 15 +++++++ gcc/c-errors.c | 2 +- gcc/c-format.c | 2 +- gcc/cp/ChangeLog | 7 +++ gcc/cp/cp-tree.h | 2 - gcc/cp/error.c | 45 +++++-------------- gcc/diagnostic.c | 40 ++++++----------- gcc/diagnostic.h | 2 +- gcc/rtl-error.c | 30 ++++++------- gcc/testsuite/ChangeLog | 6 +++ .../g++.old-deja/g++.robertl/eb133.C | 5 ++- .../g++.old-deja/g++.robertl/eb133a.C | 2 + .../g++.old-deja/g++.robertl/eb133b.C | 4 +- 13 files changed, 77 insertions(+), 85 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2c9163617a..5a31bb03b16 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2003-06-28 Nathan Sidwell + + * diagnostic.h (diagnostic_set_info): Replace file and lineno + parameters with a location_t. + * diagnostic.c (diagnostic_set_info): Replace file and lineno + parameters with a location_t. + (inform, warning, pedwarn, error, sorry, fatal_error, + internal_error, warning_with_decl, pedwarn_with_decl, + error_with_decl): Adjust. + * c-error.c (pedwarn_c99): Adjust. + * c-format.c (status_warning): Adjust. + * rtl-error.c (file_and_line_for_asm): Rename to ... + (location_for_asm): Return a location_t. + (diagnostic_for_asm): Adjust. + 2003-06-28 Neil Booth * cpptrad.c (skip_macro_block_comment): New. diff --git a/gcc/c-errors.c b/gcc/c-errors.c index de24a04afc6..2a2fdc0c440 100644 --- a/gcc/c-errors.c +++ b/gcc/c-errors.c @@ -38,7 +38,7 @@ pedwarn_c99 (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, flag_isoc99 ? pedantic_error_kind () : DK_WARNING); report_diagnostic (&diagnostic); va_end (ap); diff --git a/gcc/c-format.c b/gcc/c-format.c index 5bae1c21b4a..dc17f0e9f8b 100644 --- a/gcc/c-format.c +++ b/gcc/c-format.c @@ -1004,7 +1004,7 @@ status_warning (int *status, const char *msgid, ...) { /* This duplicates the warning function behavior. */ diagnostic_set_info (&diagnostic, _(msgid), &ap, - input_filename, input_line, DK_WARNING); + input_location, DK_WARNING); report_diagnostic (&diagnostic); } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 41ed2699640..16a909e7735 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2003-06-28 Nathan Sidwell + + * cp-tree.h (cp_line_of, cp_file_of): Remove. + * error.c (cp_line_of, cp_file_of): Merge into ... + (location_of): ... here. Make static, return a location_t. + (cp_error_at, cp_warning_at, cp_pedwarn_at): Adjust. + 2003-06-28 Nathan Sidwell PR c++/10784 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 0e3a97115f4..51243f92dae 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3820,8 +3820,6 @@ extern const char *decl_as_string (tree, int); extern const char *expr_as_string (tree, int); extern const char *context_as_string (tree, int); extern const char *lang_decl_name (tree, int); -extern const char *cp_file_of (tree); -extern int cp_line_of (tree); extern const char *language_to_string (enum languages, int); extern void print_instantiation_context (void); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index cb7c44fb9ee..a5420a7d0b5 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -113,6 +113,7 @@ static bool cp_printer (output_buffer *, text_info *); static void print_non_consecutive_character (output_buffer *, int); static void print_integer (output_buffer *, HOST_WIDE_INT); static tree locate_error (const char *, va_list); +static location_t location_of (tree); void init_error (void) @@ -2121,40 +2122,17 @@ lang_decl_name (tree decl, int v) return output_finalize_message (scratch_buffer); } -const char * -cp_file_of (tree t) +static location_t +location_of (tree t) { if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) - return DECL_SOURCE_FILE (DECL_CONTEXT (t)); + t = DECL_CONTEXT (t); else if (TYPE_P (t)) - return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t)); + t = TYPE_MAIN_DECL (t); else if (TREE_CODE (t) == OVERLOAD) - return DECL_SOURCE_FILE (OVL_FUNCTION (t)); - else - return DECL_SOURCE_FILE (t); -} - -int -cp_line_of (tree t) -{ - int line = 0; - if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) - line = DECL_SOURCE_LINE (DECL_CONTEXT (t)); - if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t) - && TYPE_MAIN_DECL (TREE_TYPE (t))) - t = TREE_TYPE (t); - - if (TYPE_P (t)) - line = DECL_SOURCE_LINE (TYPE_MAIN_DECL (t)); - else if (TREE_CODE (t) == OVERLOAD) - line = DECL_SOURCE_LINE (OVL_FUNCTION (t)); - else - line = DECL_SOURCE_LINE (t); - - if (line == 0) - return input_line; - - return line; + t = OVL_FUNCTION (t); + + return DECL_SOURCE_LOCATION (t); } /* Now the interfaces from error et al to dump_type et al. Each takes an @@ -2612,7 +2590,7 @@ cp_error_at (const char *msgid, ...) va_start (ap, msgid); diagnostic_set_info (&diagnostic, msgid, &ap, - cp_file_of (here), cp_line_of (here), DK_ERROR); + location_of (here), DK_ERROR); report_diagnostic (&diagnostic); va_end (ap); } @@ -2630,7 +2608,7 @@ cp_warning_at (const char *msgid, ...) va_start (ap, msgid); diagnostic_set_info (&diagnostic, msgid, &ap, - cp_file_of (here), cp_line_of (here), DK_WARNING); + location_of (here), DK_WARNING); report_diagnostic (&diagnostic); va_end (ap); } @@ -2648,8 +2626,7 @@ cp_pedwarn_at (const char *msgid, ...) va_start (ap, msgid); diagnostic_set_info (&diagnostic, msgid, &ap, - cp_file_of (here), cp_line_of (here), - pedantic_error_kind()); + location_of (here), pedantic_error_kind()); report_diagnostic (&diagnostic); va_end (ap); } diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 8e22a4819f5..1312ca9924e 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -761,19 +761,16 @@ text_specifies_location (text_info *text, location_t *locus) void diagnostic_set_info (diagnostic_info *diagnostic, const char *msgid, - va_list *args, const char *file, int line, + va_list *args, location_t location, diagnostic_t kind) { diagnostic->message.err_no = errno; diagnostic->message.args_ptr = args; diagnostic->message.format_spec = _(msgid); /* If the diagnostic message doesn't specify a location, - use FILE and LINE. */ + use LOCATION. */ if (!text_specifies_location (&diagnostic->message, &diagnostic->location)) - { - diagnostic->location.file = file; - diagnostic->location.line = line; - } + diagnostic->location = location; diagnostic->kind = kind; } @@ -1134,8 +1131,7 @@ inform (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, - DK_NOTE); + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_NOTE); report_diagnostic (&diagnostic); va_end (ap); } @@ -1149,8 +1145,7 @@ warning (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, - DK_WARNING); + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_WARNING); report_diagnostic (&diagnostic); va_end (ap); } @@ -1170,8 +1165,8 @@ pedwarn (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, - pedantic_error_kind ()); + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, + pedantic_error_kind ()); report_diagnostic (&diagnostic); va_end (ap); } @@ -1185,8 +1180,7 @@ error (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, - DK_ERROR); + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_ERROR); report_diagnostic (&diagnostic); va_end (ap); } @@ -1201,8 +1195,7 @@ sorry (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, - DK_SORRY); + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_SORRY); report_diagnostic (&diagnostic); va_end (ap); } @@ -1217,8 +1210,7 @@ fatal_error (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, - DK_FATAL); + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_FATAL); report_diagnostic (&diagnostic); va_end (ap); @@ -1237,8 +1229,7 @@ internal_error (const char *msgid, ...) va_list ap; va_start (ap, msgid); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, - DK_ICE); + diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_ICE); report_diagnostic (&diagnostic); va_end (ap); @@ -1263,8 +1254,7 @@ warning_with_decl (tree decl, const char *msgid, ...) return; diagnostic_set_info (&diagnostic, msgid, &ap, - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), - DK_WARNING); + DECL_SOURCE_LOCATION (decl), DK_WARNING); diagnostic_for_decl (global_dc, &diagnostic, decl); va_end (ap); } @@ -1283,8 +1273,7 @@ pedwarn_with_decl (tree decl, const char *msgid, ...) return; diagnostic_set_info (&diagnostic, msgid, &ap, - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), - pedantic_error_kind ()); + DECL_SOURCE_LOCATION (decl), pedantic_error_kind ()); diagnostic_for_decl (global_dc, &diagnostic, decl); va_end (ap); @@ -1298,8 +1287,7 @@ error_with_decl (tree decl, const char *msgid, ...) va_start (ap, msgid); diagnostic_set_info (&diagnostic, msgid, &ap, - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), - DK_ERROR); + DECL_SOURCE_LOCATION (decl), DK_ERROR); diagnostic_for_decl (global_dc, &diagnostic, decl); va_end (ap); } diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 80d6a44d68d..18a11b67354 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -298,7 +298,7 @@ extern void diagnostic_flush_buffer (diagnostic_context *); extern void diagnostic_report_diagnostic (diagnostic_context *, diagnostic_info *); extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *, - const char *, int, diagnostic_t); + location_t, diagnostic_t); extern char *diagnostic_build_prefix (diagnostic_info *); /* Pure text formatting support functions. */ diff --git a/gcc/rtl-error.c b/gcc/rtl-error.c index 5be5cd55849..028cedd2ca1 100644 --- a/gcc/rtl-error.c +++ b/gcc/rtl-error.c @@ -33,20 +33,19 @@ Boston, MA 02111-1307, USA. */ #include "intl.h" #include "diagnostic.h" -static void file_and_line_for_asm PARAMS ((rtx, const char **, int *)); +static location_t location_for_asm PARAMS ((rtx)); static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *, diagnostic_t)); -/* Figure file and line of the given INSN. */ -static void -file_and_line_for_asm (insn, pfile, pline) +/* Figure the location of the given INSN. */ +static location_t +location_for_asm (insn) rtx insn; - const char **pfile; - int *pline; { rtx body = PATTERN (insn); rtx asmop; - + location_t loc; + /* Find the (or one of the) ASM_OPERANDS in the insn. */ if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) asmop = SET_SRC (body); @@ -63,14 +62,12 @@ file_and_line_for_asm (insn, pfile, pline) if (asmop) { - *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); - *pline = ASM_OPERANDS_SOURCE_LINE (asmop); + loc.file = ASM_OPERANDS_SOURCE_FILE (asmop); + loc.line = ASM_OPERANDS_SOURCE_LINE (asmop); } else - { - *pfile = input_filename; - *pline = input_line; - } + loc = input_location; + return loc; } /* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number @@ -84,10 +81,9 @@ diagnostic_for_asm (insn, msg, args_ptr, kind) diagnostic_t kind; { diagnostic_info diagnostic; - - diagnostic_set_info (&diagnostic, msg, args_ptr, NULL, 0, kind); - file_and_line_for_asm (insn, &diagnostic.location.file, - &diagnostic.location.line); + + diagnostic_set_info (&diagnostic, msg, args_ptr, + location_for_asm (insn), kind); report_diagnostic (&diagnostic); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bc2058a0ee2..3af77db3dcb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2003-06-28 Nathan Sidwell + + * g++.old-deja/g++.robertl/eb133.C: Set expected line number. + * g++.old-deja/g++.robertl/eb133a.C: Likewise. + * g++.old-deja/g++.robertl/eb133b.C: Likewise. + 2003-06-28 Jakub Jelinek * gcc.c-torture/execute/builtins/string-8.c: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C index 685fdf18674..b6002248d55 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C @@ -3,16 +3,17 @@ // From: Klaus-Georg Adams // Reported against EGCS snaps 98/06/28. +// { dg-error "forward declaration" "" { target *-*-* } 0 } + using namespace std; int main() { try { } - catch (bad_alloc) { // { dg-error "" } parse error + catch (bad_alloc) { // { dg-error "invalid use" } return 1; } return 0; } - diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C index eb6c72d20a6..f9265851d11 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C @@ -3,6 +3,8 @@ // From: Klaus-Georg Adams // Reported against EGCS snaps 98/06/28. +// { dg-error "forward declaration" "" { target *-*-* } 0 } + int main() { try { diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C index 685fdf18674..82605146a19 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C @@ -3,13 +3,15 @@ // From: Klaus-Georg Adams // Reported against EGCS snaps 98/06/28. +// { dg-error "forward declaration" "" { target *-*-* } 0 } + using namespace std; int main() { try { } - catch (bad_alloc) { // { dg-error "" } parse error + catch (bad_alloc) { // { dg-error "invalid use" } return 1; } return 0;