mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-09 09:34:34 +08:00
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
This commit is contained in:
parent
debdeb5d70
commit
9a472a4224
@ -1,3 +1,18 @@
|
||||
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>
|
||||
|
||||
* cpptrad.c (skip_macro_block_comment): New.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
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>
|
||||
|
||||
* gcc.c-torture/execute/builtins/string-8.c: New test.
|
||||
|
@ -3,16 +3,17 @@
|
||||
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
|
||||
// Reported against EGCS snaps 98/06/28.
|
||||
|
||||
// { dg-error "forward declaration" "" { target *-*-* } 0 }
|
||||
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
|
@ -3,13 +3,15 @@
|
||||
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
|
||||
// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user