(multiline_string_line): New file scope static variable.
authorJim Wilson <wilson@gcc.gnu.org>
Thu, 31 Dec 1992 20:42:07 +0000 (12:42 -0800)
committerJim Wilson <wilson@gcc.gnu.org>
Thu, 31 Dec 1992 20:42:07 +0000 (12:42 -0800)
(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

index 6b2aaacacf1c4149c317b1feab51d0c2b3d3d4a7..a751a56e8d46fe998ff8b458398682adf2a23f9f 100644 (file)
@@ -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;
 \f
 /* 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;
   }