Commit 59495f38 by Zack Weinberg Committed by Zack Weinberg

cpperror.c (cpp_file_line_for_message): If 'line' is zero, just print "<command line>".

	* cpperror.c (cpp_file_line_for_message): If 'line' is zero,
	just print "<command line>".  If 'filename' is null or an
	empty string, print "<stdin>" for the filename.
	* cpplib.c (do_define): Don't print the 'location of the
	previous definition' message if we're still parsing the
	command line.
	(cpp_pedwarn_with_file_and_line): Always call
	cpp_file_line_for_message.

From-SVN: r31697
parent 607ace9b
2000-01-29 Zack Weinberg <zack@wolery.cumb.org>
* cpperror.c (cpp_file_line_for_message): If 'line' is zero,
just print "<command line>". If 'filename' is null or an
empty string, print "<stdin>" for the filename.
* cpplib.c (do_define): Don't print the 'location of the
previous definition' message if we're still parsing the
command line.
(cpp_pedwarn_with_file_and_line): Always call
cpp_file_line_for_message.
2000-01-29 Mark Mitchell <mark@codesourcery.com> 2000-01-29 Mark Mitchell <mark@codesourcery.com>
* flow.c (mark_regs_live_at_end): Fix typo. * flow.c (mark_regs_live_at_end): Fix typo.
......
...@@ -84,7 +84,11 @@ cpp_file_line_for_message (pfile, filename, line, column) ...@@ -84,7 +84,11 @@ cpp_file_line_for_message (pfile, filename, line, column)
const char *filename; const char *filename;
int line, column; int line, column;
{ {
if (column > 0) if (filename == 0 || *filename == '\0')
filename = "<stdin>";
if (line == 0)
fputs (_("<command line>: "), stderr);
else if (column > 0)
fprintf (stderr, "%s:%d:%d: ", filename, line, column); fprintf (stderr, "%s:%d:%d: ", filename, line, column);
else else
fprintf (stderr, "%s:%d: ", filename, line); fprintf (stderr, "%s:%d: ", filename, line);
......
...@@ -685,7 +685,7 @@ do_define (pfile, keyword) ...@@ -685,7 +685,7 @@ do_define (pfile, keyword)
mdef.symlen, mdef.symnam); mdef.symlen, mdef.symnam);
else else
cpp_pedwarn (pfile, "`%.*s' redefined", mdef.symlen, mdef.symnam); cpp_pedwarn (pfile, "`%.*s' redefined", mdef.symlen, mdef.symnam);
if (hp->type == T_MACRO) if (hp->type == T_MACRO && CPP_OPTIONS (pfile)->done_initializing)
cpp_pedwarn_with_file_and_line (pfile, hp->value.defn->file, cpp_pedwarn_with_file_and_line (pfile, hp->value.defn->file,
hp->value.defn->line, hp->value.defn->line,
"this is the location of the previous definition"); "this is the location of the previous definition");
...@@ -3474,8 +3474,7 @@ cpp_pedwarn_with_file_and_line VPARAMS ((cpp_reader *pfile, const char *file, ...@@ -3474,8 +3474,7 @@ cpp_pedwarn_with_file_and_line VPARAMS ((cpp_reader *pfile, const char *file,
if (!CPP_OPTIONS (pfile)->pedantic_errors if (!CPP_OPTIONS (pfile)->pedantic_errors
&& CPP_OPTIONS (pfile)->inhibit_warnings) && CPP_OPTIONS (pfile)->inhibit_warnings)
return; return;
if (file != NULL) cpp_file_line_for_message (pfile, file, line, -1);
cpp_file_line_for_message (pfile, file, line, -1);
v_cpp_message (pfile, CPP_OPTIONS (pfile)->pedantic_errors, msgid, ap); v_cpp_message (pfile, CPP_OPTIONS (pfile)->pedantic_errors, msgid, ap);
va_end(ap); va_end(ap);
} }
......
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