From 5b01bc66eed730a17baf459d06f2aa454b908350 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Thu, 31 Dec 1992 12:42:07 -0800 Subject: [PATCH] (multiline_string_line): New file scope static variable. (rescan): Delete multiline_string_line variable definition. (skip_quoted_string): Print start line number of unterminated string and character constants. When see a newline: warn if pedantic; delete unreachable duplicate code for traditional case; set multiline_string_line. From-SVN: r3012 --- gcc/cccp.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/cccp.c b/gcc/cccp.c index 6b2aaacacf1..a751a56e8d4 100644 --- a/gcc/cccp.c +++ b/gcc/cccp.c @@ -451,6 +451,10 @@ static int no_output; and/or warnings. */ static int done_initializing = 0; + +/* Line where a newline was first seen in a string constant. */ + +static int multiline_string_line = 0; /* I/O buffer structure. The `fname' field is nonzero for source files and #include files @@ -2177,9 +2181,6 @@ rescan (op, output_marks) this records the line it started on, for error messages. */ int start_line; - /* Line where a newline was first seen in a string constant. */ - int multiline_string_line = 0; - /* Record position of last `real' newline. */ U_CHAR *beg_of_line; @@ -6669,6 +6670,9 @@ skip_quoted_string (bp, limit, start_line, count_newlines, backslash_newlines_p, if (bp >= limit) { error_with_line (line_for_error (start_line), "unterminated string or character constant"); + error_with_line (multiline_string_line, + "possible real start of unterminated constant"); + multiline_string_line = 0; if (eofp) *eofp = 1; break; @@ -6696,22 +6700,19 @@ skip_quoted_string (bp, limit, start_line, count_newlines, backslash_newlines_p, *eofp = 1; break; } - if (match == '\'') { + if (pedantic || match == '\'') { error_with_line (line_for_error (start_line), - "unterminated character constant"); + "unterminated string or character constant"); bp--; if (eofp) *eofp = 1; break; } - if (traditional) { /* Unterminated strings are 'legal'. */ - if (eofp) - *eofp = 1; - break; - } /* If not traditional, then allow newlines inside strings. */ if (count_newlines) ++*count_newlines; + if (multiline_string_line == 0) + multiline_string_line = start_line; } else if (c == match) break; } -- 2.30.2