Commit 9a472a42 by Nathan Sidwell Committed by Nathan Sidwell

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
parent debdeb5d
2003-06-28 Nathan Sidwell <nathan@codesourcery.com>
* 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 <neil@daikokuya.co.uk> 2003-06-28 Neil Booth <neil@daikokuya.co.uk>
* cpptrad.c (skip_macro_block_comment): New. * cpptrad.c (skip_macro_block_comment): New.
......
...@@ -38,7 +38,7 @@ pedwarn_c99 (const char *msgid, ...) ...@@ -38,7 +38,7 @@ pedwarn_c99 (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); 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); flag_isoc99 ? pedantic_error_kind () : DK_WARNING);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
......
...@@ -1004,7 +1004,7 @@ status_warning (int *status, const char *msgid, ...) ...@@ -1004,7 +1004,7 @@ status_warning (int *status, const char *msgid, ...)
{ {
/* This duplicates the warning function behavior. */ /* This duplicates the warning function behavior. */
diagnostic_set_info (&diagnostic, _(msgid), &ap, diagnostic_set_info (&diagnostic, _(msgid), &ap,
input_filename, input_line, DK_WARNING); input_location, DK_WARNING);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
} }
......
2003-06-28 Nathan Sidwell <nathan@codesourcery.com> 2003-06-28 Nathan Sidwell <nathan@codesourcery.com>
* 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 <nathan@codesourcery.com>
PR c++/10784 PR c++/10784
* call.c (joust): Move warn_conversion check outwards. * call.c (joust): Move warn_conversion check outwards.
......
...@@ -3820,8 +3820,6 @@ extern const char *decl_as_string (tree, int); ...@@ -3820,8 +3820,6 @@ extern const char *decl_as_string (tree, int);
extern const char *expr_as_string (tree, int); extern const char *expr_as_string (tree, int);
extern const char *context_as_string (tree, int); extern const char *context_as_string (tree, int);
extern const char *lang_decl_name (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 const char *language_to_string (enum languages, int);
extern void print_instantiation_context (void); extern void print_instantiation_context (void);
......
...@@ -113,6 +113,7 @@ static bool cp_printer (output_buffer *, text_info *); ...@@ -113,6 +113,7 @@ static bool cp_printer (output_buffer *, text_info *);
static void print_non_consecutive_character (output_buffer *, int); static void print_non_consecutive_character (output_buffer *, int);
static void print_integer (output_buffer *, HOST_WIDE_INT); static void print_integer (output_buffer *, HOST_WIDE_INT);
static tree locate_error (const char *, va_list); static tree locate_error (const char *, va_list);
static location_t location_of (tree);
void void
init_error (void) init_error (void)
...@@ -2121,40 +2122,17 @@ lang_decl_name (tree decl, int v) ...@@ -2121,40 +2122,17 @@ lang_decl_name (tree decl, int v)
return output_finalize_message (scratch_buffer); return output_finalize_message (scratch_buffer);
} }
const char * static location_t
cp_file_of (tree t) location_of (tree t)
{ {
if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (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)) 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) else if (TREE_CODE (t) == OVERLOAD)
line = DECL_SOURCE_LINE (OVL_FUNCTION (t)); t = OVL_FUNCTION (t);
else
line = DECL_SOURCE_LINE (t); return DECL_SOURCE_LOCATION (t);
if (line == 0)
return input_line;
return line;
} }
/* Now the interfaces from error et al to dump_type et al. Each takes an /* 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, ...) ...@@ -2612,7 +2590,7 @@ cp_error_at (const char *msgid, ...)
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, diagnostic_set_info (&diagnostic, msgid, &ap,
cp_file_of (here), cp_line_of (here), DK_ERROR); location_of (here), DK_ERROR);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -2630,7 +2608,7 @@ cp_warning_at (const char *msgid, ...) ...@@ -2630,7 +2608,7 @@ cp_warning_at (const char *msgid, ...)
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, diagnostic_set_info (&diagnostic, msgid, &ap,
cp_file_of (here), cp_line_of (here), DK_WARNING); location_of (here), DK_WARNING);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -2648,8 +2626,7 @@ cp_pedwarn_at (const char *msgid, ...) ...@@ -2648,8 +2626,7 @@ cp_pedwarn_at (const char *msgid, ...)
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, diagnostic_set_info (&diagnostic, msgid, &ap,
cp_file_of (here), cp_line_of (here), location_of (here), pedantic_error_kind());
pedantic_error_kind());
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -761,19 +761,16 @@ text_specifies_location (text_info *text, location_t *locus) ...@@ -761,19 +761,16 @@ text_specifies_location (text_info *text, location_t *locus)
void void
diagnostic_set_info (diagnostic_info *diagnostic, const char *msgid, 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_t kind)
{ {
diagnostic->message.err_no = errno; diagnostic->message.err_no = errno;
diagnostic->message.args_ptr = args; diagnostic->message.args_ptr = args;
diagnostic->message.format_spec = _(msgid); diagnostic->message.format_spec = _(msgid);
/* If the diagnostic message doesn't specify a location, /* If the diagnostic message doesn't specify a location,
use FILE and LINE. */ use LOCATION. */
if (!text_specifies_location (&diagnostic->message, &diagnostic->location)) if (!text_specifies_location (&diagnostic->message, &diagnostic->location))
{ diagnostic->location = location;
diagnostic->location.file = file;
diagnostic->location.line = line;
}
diagnostic->kind = kind; diagnostic->kind = kind;
} }
...@@ -1134,8 +1131,7 @@ inform (const char *msgid, ...) ...@@ -1134,8 +1131,7 @@ inform (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_NOTE);
DK_NOTE);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -1149,8 +1145,7 @@ warning (const char *msgid, ...) ...@@ -1149,8 +1145,7 @@ warning (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_WARNING);
DK_WARNING);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -1170,8 +1165,8 @@ pedwarn (const char *msgid, ...) ...@@ -1170,8 +1165,8 @@ pedwarn (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, diagnostic_set_info (&diagnostic, msgid, &ap, input_location,
pedantic_error_kind ()); pedantic_error_kind ());
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -1185,8 +1180,7 @@ error (const char *msgid, ...) ...@@ -1185,8 +1180,7 @@ error (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_ERROR);
DK_ERROR);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -1201,8 +1195,7 @@ sorry (const char *msgid, ...) ...@@ -1201,8 +1195,7 @@ sorry (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_SORRY);
DK_SORRY);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
} }
...@@ -1217,8 +1210,7 @@ fatal_error (const char *msgid, ...) ...@@ -1217,8 +1210,7 @@ fatal_error (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_FATAL);
DK_FATAL);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
...@@ -1237,8 +1229,7 @@ internal_error (const char *msgid, ...) ...@@ -1237,8 +1229,7 @@ internal_error (const char *msgid, ...)
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_ICE);
DK_ICE);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
va_end (ap); va_end (ap);
...@@ -1263,8 +1254,7 @@ warning_with_decl (tree decl, const char *msgid, ...) ...@@ -1263,8 +1254,7 @@ warning_with_decl (tree decl, const char *msgid, ...)
return; return;
diagnostic_set_info (&diagnostic, msgid, &ap, diagnostic_set_info (&diagnostic, msgid, &ap,
DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), DECL_SOURCE_LOCATION (decl), DK_WARNING);
DK_WARNING);
diagnostic_for_decl (global_dc, &diagnostic, decl); diagnostic_for_decl (global_dc, &diagnostic, decl);
va_end (ap); va_end (ap);
} }
...@@ -1283,8 +1273,7 @@ pedwarn_with_decl (tree decl, const char *msgid, ...) ...@@ -1283,8 +1273,7 @@ pedwarn_with_decl (tree decl, const char *msgid, ...)
return; return;
diagnostic_set_info (&diagnostic, msgid, &ap, diagnostic_set_info (&diagnostic, msgid, &ap,
DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), DECL_SOURCE_LOCATION (decl), pedantic_error_kind ());
pedantic_error_kind ());
diagnostic_for_decl (global_dc, &diagnostic, decl); diagnostic_for_decl (global_dc, &diagnostic, decl);
va_end (ap); va_end (ap);
...@@ -1298,8 +1287,7 @@ error_with_decl (tree decl, const char *msgid, ...) ...@@ -1298,8 +1287,7 @@ error_with_decl (tree decl, const char *msgid, ...)
va_start (ap, msgid); va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap, diagnostic_set_info (&diagnostic, msgid, &ap,
DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), DECL_SOURCE_LOCATION (decl), DK_ERROR);
DK_ERROR);
diagnostic_for_decl (global_dc, &diagnostic, decl); diagnostic_for_decl (global_dc, &diagnostic, decl);
va_end (ap); va_end (ap);
} }
......
...@@ -298,7 +298,7 @@ extern void diagnostic_flush_buffer (diagnostic_context *); ...@@ -298,7 +298,7 @@ extern void diagnostic_flush_buffer (diagnostic_context *);
extern void diagnostic_report_diagnostic (diagnostic_context *, extern void diagnostic_report_diagnostic (diagnostic_context *,
diagnostic_info *); diagnostic_info *);
extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *, 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 *); extern char *diagnostic_build_prefix (diagnostic_info *);
/* Pure text formatting support functions. */ /* Pure text formatting support functions. */
......
...@@ -33,20 +33,19 @@ Boston, MA 02111-1307, USA. */ ...@@ -33,20 +33,19 @@ Boston, MA 02111-1307, USA. */
#include "intl.h" #include "intl.h"
#include "diagnostic.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 *, static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *,
diagnostic_t)); diagnostic_t));
/* Figure file and line of the given INSN. */ /* Figure the location of the given INSN. */
static void static location_t
file_and_line_for_asm (insn, pfile, pline) location_for_asm (insn)
rtx insn; rtx insn;
const char **pfile;
int *pline;
{ {
rtx body = PATTERN (insn); rtx body = PATTERN (insn);
rtx asmop; rtx asmop;
location_t loc;
/* Find the (or one of the) ASM_OPERANDS in the insn. */ /* Find the (or one of the) ASM_OPERANDS in the insn. */
if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
asmop = SET_SRC (body); asmop = SET_SRC (body);
...@@ -63,14 +62,12 @@ file_and_line_for_asm (insn, pfile, pline) ...@@ -63,14 +62,12 @@ file_and_line_for_asm (insn, pfile, pline)
if (asmop) if (asmop)
{ {
*pfile = ASM_OPERANDS_SOURCE_FILE (asmop); loc.file = ASM_OPERANDS_SOURCE_FILE (asmop);
*pline = ASM_OPERANDS_SOURCE_LINE (asmop); loc.line = ASM_OPERANDS_SOURCE_LINE (asmop);
} }
else else
{ loc = input_location;
*pfile = input_filename; return loc;
*pline = input_line;
}
} }
/* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number /* 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) ...@@ -84,10 +81,9 @@ diagnostic_for_asm (insn, msg, args_ptr, kind)
diagnostic_t kind; diagnostic_t kind;
{ {
diagnostic_info diagnostic; diagnostic_info diagnostic;
diagnostic_set_info (&diagnostic, msg, args_ptr, NULL, 0, kind); diagnostic_set_info (&diagnostic, msg, args_ptr,
file_and_line_for_asm (insn, &diagnostic.location.file, location_for_asm (insn), kind);
&diagnostic.location.line);
report_diagnostic (&diagnostic); report_diagnostic (&diagnostic);
} }
......
2003-06-28 Nathan Sidwell <nathan@codesourcery.com>
* 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 <jakub@redhat.com> 2003-06-28 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/builtins/string-8.c: New test. * gcc.c-torture/execute/builtins/string-8.c: New test.
......
...@@ -3,16 +3,17 @@ ...@@ -3,16 +3,17 @@
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
// Reported against EGCS snaps 98/06/28. // Reported against EGCS snaps 98/06/28.
// { dg-error "forward declaration" "" { target *-*-* } 0 }
using namespace std; using namespace std;
int main() int main()
{ {
try { try {
} }
catch (bad_alloc) { // { dg-error "" } parse error catch (bad_alloc) { // { dg-error "invalid use" }
return 1; return 1;
} }
return 0; return 0;
} }
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
// Reported against EGCS snaps 98/06/28. // Reported against EGCS snaps 98/06/28.
// { dg-error "forward declaration" "" { target *-*-* } 0 }
int main() int main()
{ {
try { try {
......
...@@ -3,13 +3,15 @@ ...@@ -3,13 +3,15 @@
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
// Reported against EGCS snaps 98/06/28. // Reported against EGCS snaps 98/06/28.
// { dg-error "forward declaration" "" { target *-*-* } 0 }
using namespace std; using namespace std;
int main() int main()
{ {
try { try {
} }
catch (bad_alloc) { // { dg-error "" } parse error catch (bad_alloc) { // { dg-error "invalid use" }
return 1; return 1;
} }
return 0; return 0;
......
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