aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-02-20 23:49:57 +0000
committerRichard Stallman <rms@gnu.org>1993-02-20 23:49:57 +0000
commit27a5574b53cc2416b91985c85d746c9f49616b76 (patch)
tree7b59973d0e46bd39bab3069b82049ad60519c853 /gcc
parent5709eb48d8c7a80b9463bd6aa58cea66f2f84672 (diff)
downloadgcc-27a5574b53cc2416b91985c85d746c9f49616b76.zip
gcc-27a5574b53cc2416b91985c85d746c9f49616b76.tar.gz
gcc-27a5574b53cc2416b91985c85d746c9f49616b76.tar.bz2
(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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cccp.c52
1 files 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: ");