From 27a5574b53cc2416b91985c85d746c9f49616b76 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Sat, 20 Feb 1993 23:49:57 +0000 Subject: [PATCH] (warning_with_line, pedwarn_with_line): New functions. (rescan): For pedantic, no error if string constant has newline, just a pedwarn. And don't end the string constant there. From-SVN: r3502 --- gcc/cccp.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/gcc/cccp.c b/gcc/cccp.c index 564fb56..5c578e3 100644 --- a/gcc/cccp.c +++ b/gcc/cccp.c @@ -2439,11 +2439,15 @@ do { ip = &instack[indepth]; \ beg_of_line = ibp; goto while2end; } - if (pedantic || c == '\'') { + if (c == '\'') { error_with_line (line_for_error (start_line), - "unterminated string or character constant"); + "unterminated character constant"); goto while2end; } + if (pedantic && multiline_string_line == 0) { + pedwarn_with_line (line_for_error (start_line), + "string constant runs past end of line"); + } if (multiline_string_line == 0) multiline_string_line = ip->lineno - 1; break; @@ -7838,6 +7842,36 @@ error_with_line (line, msg, arg1, arg2, arg3) errors++; } +static void +warning_with_line (line, msg, arg1, arg2, arg3) + int line; + char *msg; + char *arg1, *arg2, *arg3; +{ + int i; + FILE_BUF *ip = NULL; + + if (inhibit_warnings) + return; + + if (warnings_are_errors) + errors++; + + print_containing_files (); + + for (i = indepth; i >= 0; i--) + if (instack[i].fname != NULL) { + ip = &instack[i]; + break; + } + + if (ip != NULL) + fprintf (stderr, "%s:%d: ", ip->nominal_fname, line); + fprintf (stderr, "warning: "); + fprintf (stderr, msg, arg1, arg2, arg3); + fprintf (stderr, "\n"); +} + /* print an error message and maybe count it. */ void @@ -7851,6 +7885,18 @@ pedwarn (msg, arg1, arg2, arg3) warning (msg, arg1, arg2, arg3); } +void +pedwarn_with_line (line, msg, arg1, arg2, arg3) + int line; + char *msg; + char *arg1, *arg2, *arg3; +{ + if (pedantic_errors) + error_with_line (line, msg, arg1, arg2, arg3); + else + warning_with_line (line, msg, arg1, arg2, arg3); +} + /* Report a warning (or an error if pedantic_errors) giving specified file name and line number, not current. */ @@ -7866,7 +7912,7 @@ pedwarn_with_file_and_line (file, line, msg, arg1, arg2, arg3) return; if (file != NULL) fprintf (stderr, "%s:%d: ", file, line); - if (pedantic_errors || warnings_are_errors) + if (pedantic_errors) errors++; if (!pedantic_errors) fprintf (stderr, "warning: "); -- 2.7.4